Guest User

Untitled

a guest
May 20th, 2018
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.70 KB | None | 0 0
  1. AWSTemplateFormatVersion: 2010-09-09
  2. Description: Creates a RDS instance and security group to permit access to the RDS.
  3. Parameters:
  4. VpcId:
  5. Type: 'AWS::EC2::VPC::Id'
  6. Description: VpcId of your existing Virtual Private Cloud (VPC)
  7. ConstraintDescription: must be the VPC Id of an existing Virtual Private Cloud.
  8. Subnets:
  9. Type: 'List<AWS::EC2::Subnet::Id>'
  10. Description: The list of SubnetIds in your Virtual Private Cloud (VPC)
  11. ConstraintDescription: >-
  12. must be a list of at least two existing subnets associated with at least
  13. two different availability zones. They should be residing in the selected
  14. Virtual Private Cloud.
  15. DBInstanceIdentifier:
  16. Description: MySQL database name
  17. Type: String
  18. MinLength: '1'
  19. MaxLength: '64'
  20. AllowedPattern: '[a-zA-Z][a-zA-Z0-9-]*'
  21. ConstraintDescription: >-
  22. must begin with a letter and contain only alphanumeric characters or
  23. hyphens. Cannot end with a hyphen or contain two consecutive hyphens.
  24. Length 1-64.
  25. DBName:
  26. Default: MyDatabase
  27. Description: MySQL database name
  28. Type: String
  29. MinLength: '1'
  30. MaxLength: '64'
  31. AllowedPattern: '[a-zA-Z][a-zA-Z0-9_]*'
  32. ConstraintDescription: >-
  33. must begin with a letter and contain only alphanumeric characters and .
  34. Length 1-64.
  35. DBUser:
  36. NoEcho: 'true'
  37. Description: Username for MySQL database access
  38. Type: String
  39. MinLength: '1'
  40. MaxLength: '16'
  41. AllowedPattern: '[a-zA-Z][a-zA-Z0-9_]*'
  42. ConstraintDescription: >-
  43. must begin with a letter and contain only alphanumeric characters _. Length
  44. 1-16.
  45. DBPassword:
  46. NoEcho: 'true'
  47. Description: Password for MySQL database access
  48. Type: String
  49. MinLength: '8'
  50. MaxLength: '41'
  51. AllowedPattern: '[a-zA-Z0-9]*'
  52. ConstraintDescription: must contain only alphanumeric characters. Length 8-41.
  53. DBAllocatedStorage:
  54. Default: '5'
  55. Description: The size of the database (Gb)
  56. Type: Number
  57. MinValue: '5'
  58. MaxValue: '1024'
  59. ConstraintDescription: must be between 5 and 1024Gb.
  60. DBInstanceClass:
  61. Description: The database instance type
  62. Type: String
  63. Default: db.t2.small
  64. AllowedValues:
  65. - db.t1.micro
  66. - db.m1.small
  67. - db.m1.medium
  68. - db.m1.large
  69. - db.m1.xlarge
  70. - db.m2.xlarge
  71. - db.m2.2xlarge
  72. - db.m2.4xlarge
  73. - db.m3.medium
  74. - db.m3.large
  75. - db.m3.xlarge
  76. - db.m3.2xlarge
  77. - db.m4.large
  78. - db.m4.xlarge
  79. - db.m4.2xlarge
  80. - db.m4.4xlarge
  81. - db.m4.10xlarge
  82. - db.r3.large
  83. - db.r3.xlarge
  84. - db.r3.2xlarge
  85. - db.r3.4xlarge
  86. - db.r3.8xlarge
  87. - db.m2.xlarge
  88. - db.m2.2xlarge
  89. - db.m2.4xlarge
  90. - db.cr1.8xlarge
  91. - db.t2.micro
  92. - db.t2.small
  93. - db.t2.medium
  94. - db.t2.large
  95. ConstraintDescription: must select a valid database instance type.
  96. DBEngineVersion:
  97. Description: The mysql version
  98. Type: String
  99. Default: 5.7
  100. AllowedValues:
  101. - 5.7
  102. - 5.6
  103. - 5.5
  104. ConstraintDescription: must select a valid mysql version.
  105. MultiAZDatabase:
  106. Default: 'true'
  107. Description: Create a multi-AZ MySQL Amazon RDS database instance
  108. Type: String
  109. AllowedValues:
  110. - 'true'
  111. - 'false'
  112. ConstraintDescription: must be either true or false.
  113. PubliclyAccessible:
  114. Default: 'false'
  115. Description: Create an public MySQL Amazon RDS database instance
  116. Type: String
  117. AllowedValues:
  118. - 'true'
  119. - 'false'
  120. ConstraintDescription: must be either true or false.
  121. Encrypted:
  122. Default: 'true'
  123. Description: Create an encrypted MySQL Amazon RDS database instance
  124. Type: String
  125. AllowedValues:
  126. - 'true'
  127. - 'false'
  128. ConstraintDescription: must be either true or false.
  129. Resources:
  130. ApplicationSecurityGroup:
  131. Type: 'AWS::EC2::SecurityGroup'
  132. Properties:
  133. GroupDescription: Application security group used by RDS for access
  134. VpcId: !Ref VpcId
  135. Metadata:
  136. 'AWS::CloudFormation::Designer':
  137. id: 94a2e578-063e-4ed4-9a77-390a7c7efa31
  138. RDSSecurityGroup:
  139. Type: 'AWS::EC2::SecurityGroup'
  140. Properties:
  141. GroupDescription: RDS security group
  142. SecurityGroupIngress:
  143. - IpProtocol: tcp
  144. FromPort: '3306'
  145. ToPort: '3306'
  146. SourceSecurityGroupId: !Ref ApplicationSecurityGroup
  147. VpcId: !Ref VpcId
  148. Metadata:
  149. 'AWS::CloudFormation::Designer':
  150. id: 6ee6b6d7-415f-4f86-bf57-cef2bd61af1a
  151. MySQLDatabase:
  152. Type: 'AWS::RDS::DBInstance'
  153. Properties:
  154. Engine: MySQL
  155. EngineVersion: !Ref DBEngineVersion
  156. DBName: !Ref DBName
  157. MultiAZ: !Ref MultiAZDatabase
  158. MasterUsername: !Ref DBUser
  159. MasterUserPassword: !Ref DBPassword
  160. DBInstanceIdentifier: !Ref DBInstanceIdentifier
  161. DBInstanceClass: !Ref DBInstanceClass
  162. AllocatedStorage: !Ref DBAllocatedStorage
  163. StorageEncrypted: !Ref Encrypted
  164. PubliclyAccessible: !Ref PubliclyAccessible
  165. VPCSecurityGroups:
  166. - !GetAtt
  167. - RDSSecurityGroup
  168. - GroupId
  169. Metadata:
  170. 'AWS::CloudFormation::Designer':
  171. id: 10352a1a-e151-4203-8089-2bde6c8de2de
  172. Metadata:
  173. 'AWS::CloudFormation::Designer':
  174. 94a2e578-063e-4ed4-9a77-390a7c7efa31:
  175. size:
  176. width: 60
  177. height: 60
  178. position:
  179. x: 60
  180. 'y': 210
  181. z: 1
  182. embeds: []
  183. 6ee6b6d7-415f-4f86-bf57-cef2bd61af1a:
  184. size:
  185. width: 60
  186. height: 60
  187. position:
  188. x: 180
  189. 'y': 210
  190. z: 1
  191. embeds: []
  192. 10352a1a-e151-4203-8089-2bde6c8de2de:
  193. size:
  194. width: 60
  195. height: 60
  196. position:
  197. x: 330
  198. 'y': 210
  199. z: 1
  200. embeds: []
  201. isassociatedwith:
  202. - 6ee6b6d7-415f-4f86-bf57-cef2bd61af1a
Add Comment
Please, Sign In to add comment