Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.41 KB | None | 0 0
  1. {
  2. "Outputs": {
  3. "RDSHost": {
  4. "Description": "Database endpoint address",
  5. "Value": { "Fn::GetAtt": ["RDSDatabase", "Endpoint.Address"] }
  6. },
  7. "RDSPort": {
  8. "Description": "Database endpoint port",
  9. "Value": { "Fn::GetAtt": ["RDSDatabase", "Endpoint.Port"] }
  10. },
  11. "RDSPassSecurityGroup": {
  12. "Description": "Security group assign to ec2 instance that need access to rds instance",
  13. "Value": {
  14. "Ref": "RDSPassSecurityGroup"
  15. }
  16. },
  17. "MessageQueueName": {
  18. "Value": {
  19. "Fn::GetAtt": [
  20. "MessageQueue",
  21. "QueueName"
  22. ]
  23. }
  24. },
  25. "MessageQueueUrl": {
  26. "Value": { "Ref": "MessageQueue" }
  27. },
  28. "DeadLetterQueueName": {
  29. "Value": {
  30. "Fn::GetAtt": [
  31. "DeadLetterQueue",
  32. "QueueName"
  33. ]
  34. }
  35. },
  36. "DeadLetterQueueUrl": {
  37. "Value": { "Ref": "DeadLetterQueue" }
  38. },
  39. "InstanceProfile": {
  40. "Description": "Instance profile that should be asigned to ec2 instance",
  41. "Value": {
  42. "Ref": "InstanceProfile"
  43. }
  44. }
  45. },
  46.  
  47. "Parameters": {
  48. "env": {
  49. "Description": "Deployment environment name",
  50. "Type": "String"
  51. },
  52. "QueuePrefix": {
  53. "Description": "Message Queue Base Name",
  54. "Type": "String"
  55. },
  56. "DBUser": {
  57. "NoEcho": "false",
  58. "Description": "The name of master user for the client DB Instance.",
  59. "Type": "String",
  60. "ConstraintDescription": "must begin with a letter and contain only alphanumeric characters"
  61. },
  62.  
  63. "DBName": {
  64. "NoEcho": "false",
  65. "Description": "The DB Name of the RDS instance",
  66. "Type": "String",
  67. "ConstraintDescription": "must contain only alphanumeric characters"
  68. },
  69.  
  70. "DBPassword": {
  71. "NoEcho": "true",
  72. "Description": "The master password for the DB instance.",
  73. "Type": "String",
  74. "ConstraintDescription": "must contain only alphanumeric characters"
  75. }
  76. },
  77.  
  78. "Resources": {
  79. "DeadLetterQueue": { "Type": "AWS::SQS::Queue" },
  80. "MessageQueue": {
  81. "Type": "AWS::SQS::Queue",
  82. "Properties": {
  83. "ReceiveMessageWaitTimeSeconds": 20,
  84. "VisibilityTimeout": 600,
  85. "QueueName": {
  86. "Fn::Join": [
  87. "-",
  88. [ { "Ref": "QueuePrefix" }, { "Ref": "env" } ]
  89. ]
  90. },
  91. "RedrivePolicy": {
  92. "maxReceiveCount": 10,
  93. "deadLetterTargetArn": {
  94. "Fn::GetAtt": [
  95. "DeadLetterQueue",
  96. "Arn"
  97. ]
  98. }
  99. }
  100. }
  101. },
  102. "Role": {
  103. "Type": "AWS::IAM::Role",
  104. "Properties": {
  105. "AssumeRolePolicyDocument": {
  106. "Statement": [
  107. {
  108. "Effect": "Allow",
  109. "Principal": {
  110. "Service": [
  111. "ec2.amazonaws.com"
  112. ]
  113. },
  114. "Action": [
  115. "sts:AssumeRole"
  116. ]
  117. }
  118. ]
  119. },
  120. "Path": "/",
  121. "Policies": [
  122. {
  123. "PolicyName": "S3Access",
  124. "PolicyDocument": {
  125. "Statement": [
  126. {
  127. "Effect": "Allow",
  128. "Action": [
  129. "s3:Get*",
  130. "s3:List*",
  131. "s3:PutObject"
  132. ],
  133. "Resource": "*"
  134. }
  135. ]
  136. }
  137. },
  138. {
  139. "PolicyName": "SQSAccess",
  140. "PolicyDocument": {
  141. "Statement": [
  142. {
  143. "Effect": "Allow",
  144. "Action": [
  145. "sqs:ChangeMessageVisibility",
  146. "sqs:DeleteMessage",
  147. "sqs:ReceiveMessage",
  148. "sqs:SendMessage"
  149. ],
  150. "Resource": "*"
  151. }
  152. ]
  153. }
  154. },
  155. {
  156. "PolicyName": "CloudWatchAccess",
  157. "PolicyDocument": {
  158. "Statement": [
  159. {
  160. "Effect": "Allow",
  161. "Action": [
  162. "cloudwatch:PutMetricData"
  163. ],
  164. "Resource": "*"
  165. }
  166. ]
  167. }
  168. },
  169. {
  170. "PolicyName": "DynamoPeriodicTasks",
  171. "PolicyDocument": {
  172. "Statement": [
  173. {
  174. "Effect": "Allow",
  175. "Action": [
  176. "dynamodb:BatchGetItem",
  177. "dynamodb:BatchWriteItem",
  178. "dynamodb:DeleteItem",
  179. "dynamodb:GetItem",
  180. "dynamodb:PutItem",
  181. "dynamodb:Query",
  182. "dynamodb:Scan",
  183. "dynamodb:UpdateItem"
  184. ],
  185. "Resource": "*"
  186. }
  187. ]
  188. }
  189. }
  190. ]
  191. }
  192. },
  193. "InstanceProfile": {
  194. "Type": "AWS::IAM::InstanceProfile",
  195. "Properties": {
  196. "Path": "/",
  197. "Roles": [
  198. {
  199. "Ref": "Role"
  200. }
  201. ]
  202. }
  203. },
  204. "RDSDBSecurityGroup": {
  205. "Type": "AWS::RDS::DBSecurityGroup",
  206. "Properties": {
  207. "GroupDescription": "Enable database access to Beanstalk application",
  208. "DBSecurityGroupIngress": {
  209. "EC2SecurityGroupName": {
  210. "Ref": "RDSPassSecurityGroup"
  211. }
  212. }
  213. }
  214. },
  215.  
  216. "RDSDatabase": {
  217. "Type": "AWS::RDS::DBInstance",
  218. "DeletionPolicy": "Delete",
  219. "Properties": {
  220. "MasterUsername": {
  221. "Ref": "DBUser"
  222. },
  223. "DBSecurityGroups": [
  224. {
  225. "Ref": "RDSDBSecurityGroup"
  226. }
  227. ],
  228. "DBInstanceClass": "db.m1.small",
  229. "AllocatedStorage": "5",
  230. "MultiAZ": "false",
  231. "EngineVersion": "9.3.5",
  232. "DBName": {
  233. "Ref": "DBName"
  234. },
  235. "MasterUserPassword": {
  236. "Ref": "DBPassword"
  237. },
  238. "Engine": "postgres"
  239. }
  240. },
  241.  
  242. "RDSPassSecurityGroup": {
  243. "Type": "AWS::EC2::SecurityGroup",
  244. "Properties": {
  245. "GroupDescription": "SecurityGroup access RDS database."
  246. }
  247. }
  248. }
  249. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement