Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AWSTemplateFormatVersion: 2010-09-09
- Description: Creates a RDS instance and security group to permit access to the RDS.
- Parameters:
- VpcId:
- Type: 'AWS::EC2::VPC::Id'
- Description: VpcId of your existing Virtual Private Cloud (VPC)
- ConstraintDescription: must be the VPC Id of an existing Virtual Private Cloud.
- Subnets:
- Type: 'List<AWS::EC2::Subnet::Id>'
- Description: The list of SubnetIds in your Virtual Private Cloud (VPC)
- ConstraintDescription: >-
- must be a list of at least two existing subnets associated with at least
- two different availability zones. They should be residing in the selected
- Virtual Private Cloud.
- DBInstanceIdentifier:
- Description: MySQL database name
- Type: String
- MinLength: '1'
- MaxLength: '64'
- AllowedPattern: '[a-zA-Z][a-zA-Z0-9-]*'
- ConstraintDescription: >-
- must begin with a letter and contain only alphanumeric characters or
- hyphens. Cannot end with a hyphen or contain two consecutive hyphens.
- Length 1-64.
- DBName:
- Default: MyDatabase
- Description: MySQL database name
- Type: String
- MinLength: '1'
- MaxLength: '64'
- AllowedPattern: '[a-zA-Z][a-zA-Z0-9_]*'
- ConstraintDescription: >-
- must begin with a letter and contain only alphanumeric characters and .
- Length 1-64.
- DBUser:
- NoEcho: 'true'
- Description: Username for MySQL database access
- Type: String
- MinLength: '1'
- MaxLength: '16'
- AllowedPattern: '[a-zA-Z][a-zA-Z0-9_]*'
- ConstraintDescription: >-
- must begin with a letter and contain only alphanumeric characters _. Length
- 1-16.
- DBPassword:
- NoEcho: 'true'
- Description: Password for MySQL database access
- Type: String
- MinLength: '8'
- MaxLength: '41'
- AllowedPattern: '[a-zA-Z0-9]*'
- ConstraintDescription: must contain only alphanumeric characters. Length 8-41.
- DBAllocatedStorage:
- Default: '5'
- Description: The size of the database (Gb)
- Type: Number
- MinValue: '5'
- MaxValue: '1024'
- ConstraintDescription: must be between 5 and 1024Gb.
- DBInstanceClass:
- Description: The database instance type
- Type: String
- Default: db.t2.small
- AllowedValues:
- - db.t1.micro
- - db.m1.small
- - db.m1.medium
- - db.m1.large
- - db.m1.xlarge
- - db.m2.xlarge
- - db.m2.2xlarge
- - db.m2.4xlarge
- - db.m3.medium
- - db.m3.large
- - db.m3.xlarge
- - db.m3.2xlarge
- - db.m4.large
- - db.m4.xlarge
- - db.m4.2xlarge
- - db.m4.4xlarge
- - db.m4.10xlarge
- - db.r3.large
- - db.r3.xlarge
- - db.r3.2xlarge
- - db.r3.4xlarge
- - db.r3.8xlarge
- - db.m2.xlarge
- - db.m2.2xlarge
- - db.m2.4xlarge
- - db.cr1.8xlarge
- - db.t2.micro
- - db.t2.small
- - db.t2.medium
- - db.t2.large
- ConstraintDescription: must select a valid database instance type.
- DBEngineVersion:
- Description: The mysql version
- Type: String
- Default: 5.7
- AllowedValues:
- - 5.7
- - 5.6
- - 5.5
- ConstraintDescription: must select a valid mysql version.
- MultiAZDatabase:
- Default: 'true'
- Description: Create a multi-AZ MySQL Amazon RDS database instance
- Type: String
- AllowedValues:
- - 'true'
- - 'false'
- ConstraintDescription: must be either true or false.
- PubliclyAccessible:
- Default: 'false'
- Description: Create an public MySQL Amazon RDS database instance
- Type: String
- AllowedValues:
- - 'true'
- - 'false'
- ConstraintDescription: must be either true or false.
- Encrypted:
- Default: 'true'
- Description: Create an encrypted MySQL Amazon RDS database instance
- Type: String
- AllowedValues:
- - 'true'
- - 'false'
- ConstraintDescription: must be either true or false.
- Resources:
- ApplicationSecurityGroup:
- Type: 'AWS::EC2::SecurityGroup'
- Properties:
- GroupDescription: Application security group used by RDS for access
- VpcId: !Ref VpcId
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: 94a2e578-063e-4ed4-9a77-390a7c7efa31
- RDSSecurityGroup:
- Type: 'AWS::EC2::SecurityGroup'
- Properties:
- GroupDescription: RDS security group
- SecurityGroupIngress:
- - IpProtocol: tcp
- FromPort: '3306'
- ToPort: '3306'
- SourceSecurityGroupId: !Ref ApplicationSecurityGroup
- VpcId: !Ref VpcId
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: 6ee6b6d7-415f-4f86-bf57-cef2bd61af1a
- MySQLDatabase:
- Type: 'AWS::RDS::DBInstance'
- Properties:
- Engine: MySQL
- EngineVersion: !Ref DBEngineVersion
- DBName: !Ref DBName
- MultiAZ: !Ref MultiAZDatabase
- MasterUsername: !Ref DBUser
- MasterUserPassword: !Ref DBPassword
- DBInstanceIdentifier: !Ref DBInstanceIdentifier
- DBInstanceClass: !Ref DBInstanceClass
- AllocatedStorage: !Ref DBAllocatedStorage
- StorageEncrypted: !Ref Encrypted
- PubliclyAccessible: !Ref PubliclyAccessible
- VPCSecurityGroups:
- - !GetAtt
- - RDSSecurityGroup
- - GroupId
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: 10352a1a-e151-4203-8089-2bde6c8de2de
- Metadata:
- 'AWS::CloudFormation::Designer':
- 94a2e578-063e-4ed4-9a77-390a7c7efa31:
- size:
- width: 60
- height: 60
- position:
- x: 60
- 'y': 210
- z: 1
- embeds: []
- 6ee6b6d7-415f-4f86-bf57-cef2bd61af1a:
- size:
- width: 60
- height: 60
- position:
- x: 180
- 'y': 210
- z: 1
- embeds: []
- 10352a1a-e151-4203-8089-2bde6c8de2de:
- size:
- width: 60
- height: 60
- position:
- x: 330
- 'y': 210
- z: 1
- embeds: []
- isassociatedwith:
- - 6ee6b6d7-415f-4f86-bf57-cef2bd61af1a
Add Comment
Please, Sign In to add comment