Last active
March 11, 2022 19:46
-
-
Save youngsoul/cc639fbc3d8e09ce7969920f301ca3a9 to your computer and use it in GitHub Desktop.
Example of creating a MySQL 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
rds_instance = rds.DatabaseInstance(self, | |
id=f'{resource_prefix}-DBInstance', | |
engine=rds.DatabaseInstanceEngine.mysql( | |
version=rds.MysqlEngineVersion.VER_8_0_16), | |
credentials=rds.Credentials.from_secret(db_credentials_secret), | |
instance_type= | |
ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO), | |
vpc=vpc, | |
vpc_subnets=ec2.SubnetSelection( | |
subnet_type=ec2.SubnetType.PRIVATE_ISOLATED | |
), | |
database_name=db_name, | |
port=mysql_port, | |
removal_policy=RemovalPolicy.DESTROY, | |
deletion_protection=False, | |
security_groups=[db_connection_sg], | |
publicly_accessible=False, | |
multi_az=False # default value: False | |
) | |
proxy = rds_instance.add_proxy(construct_id + '-proxy', | |
secrets=[db_credentials_secret], | |
debug_logging=True, | |
vpc=vpc, | |
require_tls=False, | |
security_groups=[db_connection_sg]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment