Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
omenking committed Apr 12, 2024
1 parent 37c17b4 commit 9789010
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dms/serverless/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mysql://admin:password@<hostname>:5432/mydatabase


mysql -u admin -ppassword -h database-2.ck6c4llggxsy.us-east-1.rds.amazonaws.com -P 5432 database
psql postgresql://postgres:password@database-2.ck6c4llggxsy.us-east-1.rds.amazonaws.com:3306/mydatabase
psql postgresql://postgres:password@rds-dms-postgres-rdsinstance-ghj0ttbqkmaf.cv1x0r3utzcm.ca-central-1.rds.amazonaws.com:3306/mydatabase



14 changes: 14 additions & 0 deletions dms/serverless/bin/deploy_mysql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

echo "== deploy rds"

STACK_NAME="rds-dms-mysql"

# https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html
aws cloudformation deploy \
--template-file cfn/mysql.yaml \
--capabilities CAPABILITY_NAMED_IAM \
--no-execute-changeset \
--parameter-overrides VpcId="vpc-08f0ec02f7471b018" Subnets="subnet-0e0fd31733061237d,subnet-0377c6b172e2951d4,subnet-0d8058cb02f147a86" \
--region ca-central-1 \
--stack-name $STACK_NAME
14 changes: 14 additions & 0 deletions dms/serverless/bin/deploy_postgres
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

echo "== deploy rds"

STACK_NAME="rds-dms-postgres"

# https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html
aws cloudformation deploy \
--template-file cfn/postgres.yaml \
--capabilities CAPABILITY_NAMED_IAM \
--no-execute-changeset \
--parameter-overrides VpcId="vpc-08f0ec02f7471b018" Subnets="subnet-0e0fd31733061237d,subnet-0377c6b172e2951d4,subnet-0d8058cb02f147a86" \
--region us-east-1 \
--stack-name $STACK_NAME
104 changes: 104 additions & 0 deletions dms/serverless/cfn/mysql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
AWSTemplateFormatVersion: 2010-09-09
Description: RDS Postgress
Parameters:
VpcId:
Type: String
Username:
Type: String
Default: admin
Password:
Type: String
Default: password
BackupRetentionPeriod:
Type: Number
Default: 0
InstanceClass:
Type: String
Default: db.t3.micro
Engine:
Type: String
Default: mysql
EngineVersion:
Type: String
Default: 8.0.35
PubliclyAccessible:
Type: String
AllowedValues:
- true
- false
Default: true
DeletionProtection:
Type: String
AllowedValues:
- true
- false
Default: false
RdsDatabaseName:
Type: String
Default: "mydatabase"
RdsPort:
Type: Number
Default: 3306
Subnets:
Type: 'List<AWS::EC2::Subnet::Id>'
Description: A list of subnets for the Auto Scaling group
Resources:
DbSg:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: !Sub "Security Group for RDS Instance"
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: !Ref RdsPort
ToPort: !Ref RdsPort
CidrIp: 0.0.0.0/0
SecurityGroupEgress:
- IpProtocol: -1
FromPort: -1
ToPort: -1
CidrIp: 0.0.0.0/0
VpcId: !Ref VpcId
DBSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: "My DB Subnet Group"
SubnetIds: !Ref Subnets

RdsInstance:
Type: AWS::RDS::DBInstance
DeletionPolicy: 'Delete'
UpdateReplacePolicy: 'Delete'
Properties:
MasterUsername: !Ref Username
MasterUserPassword: !Ref Password
DBSubnetGroupName: !Ref DBSubnetGroup
AllocatedStorage: '20'
AllowMajorVersionUpgrade: true
AutoMinorVersionUpgrade: true
# This should be turned off When using AuthIAM on the Proxy.
Port: !Ref RdsPort
EnableIAMDatabaseAuthentication: false
BackupRetentionPeriod: !Ref BackupRetentionPeriod
DBInstanceClass: !Ref InstanceClass
DBName: !Ref RdsDatabaseName
Engine: !Ref Engine
DeletionProtection: !Ref DeletionProtection
EngineVersion: !Ref EngineVersion
PubliclyAccessible: !Ref PubliclyAccessible
VPCSecurityGroups:
- !GetAtt DbSg.GroupId
Outputs:
StackName:
Value: !Ref AWS::StackName
RdsUsername:
Value: !Ref Username
Export:
Name: !Sub ${AWS::StackName}RdsUsername
RdsPort:
Value: !Ref RdsPort
Export:
Name: !Sub ${AWS::StackName}RdsPort
RdsDatabaseName:
Value: !Ref RdsDatabaseName
Export:
Name: !Sub ${AWS::StackName}RdsDatabaseName
104 changes: 104 additions & 0 deletions dms/serverless/cfn/postgres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
AWSTemplateFormatVersion: 2010-09-09
Description: RDS Postgress
Parameters:
VpcId:
Type: String
Username:
Type: String
Default: postgres
Password:
Type: String
Default: password
BackupRetentionPeriod:
Type: Number
Default: 0
InstanceClass:
Type: String
Default: db.t3.micro
Engine:
Type: String
Default: postgres
EngineVersion:
Type: String
Default: 15.4
PubliclyAccessible:
Type: String
AllowedValues:
- true
- false
Default: true
DeletionProtection:
Type: String
AllowedValues:
- true
- false
Default: false
RdsDatabaseName:
Type: String
Default: "mydatabase"
RdsPort:
Type: Number
Default: 5432
Subnets:
Type: 'List<AWS::EC2::Subnet::Id>'
Description: A list of subnets for the Auto Scaling group
Resources:
DbSg:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: !Sub "Security Group for RDS Instance"
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: !Ref RdsPort
ToPort: !Ref RdsPort
CidrIp: 0.0.0.0/0
SecurityGroupEgress:
- IpProtocol: -1
FromPort: -1
ToPort: -1
CidrIp: 0.0.0.0/0
VpcId: !Ref VpcId
DBSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: "My DB Subnet Group"
SubnetIds: !Ref Subnets

RdsInstance:
Type: AWS::RDS::DBInstance
DeletionPolicy: 'Delete'
UpdateReplacePolicy: 'Delete'
Properties:
MasterUsername: !Ref Username
MasterUserPassword: !Ref Password
DBSubnetGroupName: !Ref DBSubnetGroup
AllocatedStorage: '20'
AllowMajorVersionUpgrade: true
AutoMinorVersionUpgrade: true
# This should be turned off When using AuthIAM on the Proxy.
Port: !Ref RdsPort
EnableIAMDatabaseAuthentication: false
BackupRetentionPeriod: !Ref BackupRetentionPeriod
DBInstanceClass: !Ref InstanceClass
DBName: !Ref RdsDatabaseName
Engine: !Ref Engine
DeletionProtection: !Ref DeletionProtection
EngineVersion: !Ref EngineVersion
PubliclyAccessible: !Ref PubliclyAccessible
VPCSecurityGroups:
- !GetAtt DbSg.GroupId
Outputs:
StackName:
Value: !Ref AWS::StackName
RdsUsername:
Value: !Ref Username
Export:
Name: !Sub ${AWS::StackName}RdsUsername
RdsPort:
Value: !Ref RdsPort
Export:
Name: !Sub ${AWS::StackName}RdsPort
RdsDatabaseName:
Value: !Ref RdsDatabaseName
Export:
Name: !Sub ${AWS::StackName}RdsDatabaseName

0 comments on commit 9789010

Please sign in to comment.