AWSTemplateFormatVersion: 2010-09-09 Description: >- Description": "AWS CloudFormation Sample Template for creating an Amazon RDS DB instance: Sample template showing how to create a DB instance with Enhanced Monitoring enabled. **WARNING** This template creates an RDS DB instance. You will be billed for the AWS resources used if you create a stack from this template. Parameters: VPCid: Type: String Default: vpc-03b47005fe7db946d DBInstanceID: Default: demordsmyqldbinstance Description: My database instance Type: String MinLength: '1' MaxLength: '63' AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*' ConstraintDescription: >- Must begin with a letter and must not end with a hyphen or contain two consecutive hyphens. DBName: Default: demordsmyqldb Description: My database 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. DBInstanceClass: Default: db.m5.large Description: DB instance class Type: String ConstraintDescription: Must select a valid DB instance type. DBAllocatedStorage: Default: '50' Description: The size of the database (GiB) Type: Number MinValue: '5' MaxValue: '1024' ConstraintDescription: must be between 20 and 65536 GiB. DBUsername: NoEcho: 'true' Default : mydbuser 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. DBPassword: NoEcho: 'true' Default: mydbuserpasswd Description: Password MySQL database access Type: String MinLength: '8' MaxLength: '41' AllowedPattern: '[a-zA-Z0-9]*' ConstraintDescription: must contain only alphanumeric characters. Resources: DBSubnet1: Type: AWS::EC2::Subnet Properties: VpcId: !Ref VPCid CidrBlock: 10.0.16.0/24 AvailabilityZone: "us-west-2a" DBSubnet2: Type: AWS::EC2::Subnet Properties: VpcId: !Ref VPCid CidrBlock: 10.0.17.0/24 AvailabilityZone: "us-west-2b" DBSubnetGroup: Properties: DBSubnetGroupDescription: description SubnetIds: - !Ref DBSubnet1 - !Ref DBSubnet2 Type: "AWS::RDS::DBSubnetGroup" PrivateSubnetRouteTable: Type: AWS::EC2::RouteTable Properties: VpcId: !Ref VPCid Tags: - Key: Name Value: !Sub 'Public Subnet Route table for ${AWS::StackName}' PrivateSubnet1RouteTableAssociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: SubnetId: !Ref DBSubnet1 RouteTableId: !Ref PrivateSubnetRouteTable PrivateSubnet2RouteTableAssociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: SubnetId: !Ref DBSubnet2 RouteTableId: !Ref PrivateSubnetRouteTable RDSSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: Allow http to client host VpcId: !Ref VPCid SecurityGroupIngress: - IpProtocol: tcp FromPort: 3306 ToPort: 3306 CidrIp: 10.0.0.0/16 SecurityGroupEgress: - IpProtocol: '-1' FromPort: '-1' ToPort: '-1' CidrIp: 0.0.0.0/0 MyDB: Type: 'AWS::RDS::DBInstance' Properties: DBInstanceIdentifier: !Ref DBInstanceID DBName: !Ref DBName DBInstanceClass: !Ref DBInstanceClass AllocatedStorage: !Ref DBAllocatedStorage Engine: MySQL EngineVersion: 8.0.16 MasterUsername: !Ref DBUsername MasterUserPassword: !Ref DBPassword DBSubnetGroupName: !Ref DBSubnetGroup MultiAZ: false PubliclyAccessible: false VPCSecurityGroups: - !Ref RDSSecurityGroup Outputs: EndpointAddress: Value: !GetAtt MyDB.Endpoint.Address