Created
October 31, 2018 18:47
-
-
Save xschildw/239f7f1f1b1b5d2889c5268f765c03d5 to your computer and use it in GitHub Desktop.
Cloudformation script to deploy database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Description: AWS CloudFormation template to create an RDS instance for the warehouse workers build | |
| Parameters: | |
| DBAllocatedStorage: | |
| Default: '5' | |
| Description: The size of the database (Gb) | |
| Type: Number | |
| DBClass: | |
| Default: db.t2.micro | |
| Description: Database instance class | |
| Type: String | |
| DBName: | |
| Default: MyDb | |
| Description: The database name | |
| MaxLength: '64' | |
| MinLength: '1' | |
| Type: String | |
| DBPassword: | |
| Description: The database admin account password | |
| NoEcho: true | |
| Type: String | |
| DBUser: | |
| Description: The database admin account username | |
| NoEcho: true | |
| Type: String | |
| Subnets: | |
| Description: List of subnetIds spanning 2 availability zones | |
| Type: CommaDelimitedList | |
| VpcId: | |
| Description: VpcId of the VPC to deploy in | |
| Type: String | |
| Resources: | |
| DBSubnetGroup: | |
| Type: AWS::RDS::DBSubnetGroup | |
| Properties: | |
| DBSubnetGroupDescription: Subnets for DB instance | |
| SubnetIds: !Ref 'Subnets' | |
| VpcSecurityGroup: | |
| Type: AWS::EC2::SecurityGroup | |
| Properties: | |
| GroupDescription: Security group for DB instances | |
| VpcId: !Ref 'VpcId' | |
| SecurityGroupIngress: | |
| - | |
| Description: "VPN traffic" | |
| CidrIp: '10.1.0.0/16' | |
| FromPort: '3306' | |
| ToPort: '3306' | |
| IpProtocol: 'tcp' | |
| - | |
| Description: "SynapseDev-VPC" | |
| CidrIp: '10.21.0.0/16' | |
| FromPort: '3306' | |
| ToPort: '3306' | |
| IpProtocol: 'tcp' | |
| WarehouseDB: | |
| Type: AWS::RDS::DBInstance | |
| Properties: | |
| AllocatedStorage: !Ref 'DBAllocatedStorage' | |
| DBInstanceClass: !Ref 'DBClass' | |
| DBName: !Ref 'DBName' | |
| DBSubnetGroupName: !Ref 'DBSubnetGroup' | |
| Engine: MySQL | |
| EngineVersion: 5.6.34 | |
| MasterUserPassword: !Ref 'DBPassword' | |
| MasterUsername: !Ref 'DBUser' | |
| VPCSecurityGroups: | |
| - !Ref 'VpcSecurityGroup' | |
| Outputs: | |
| JDBCConnectionString: | |
| Description: JDBC connection string for database instance | |
| Value: !Join | |
| - '' | |
| - - jdbc:mysql:// | |
| - !GetAtt 'WarehouseDB.Endpoint.Address' | |
| - !GetAtt 'WarehouseDB.Endpoint.Port' | |
| - / | |
| - !Ref 'DBName' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment