Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On aws-rds on aws-cdk, where is the setting to make database publicly accessible?

With AWS RDS, the console and the CLI/API both have a switch to make the database publicly accessible, but I cannot find a way to do this with the new aws-cdk using the constructs provided. There is a boolean for this in the Cloud Formation classes (e.g. CfnDBInstance), but I can't find documentation on how to use that in combination with the constructs. The CDK is pretty amazing, and it set up everything perfectly with just a few lines of code, except for this one piece.

like image 569
dustincarr Avatar asked Jul 26 '19 13:07

dustincarr


People also ask

What is public accessibility in AWS RDS?

Ensure that the RDS instance has the publicly accessible attribute set so that it is assigned a public address. Also according to the AWS RDS docs, "If you want your DB instance in the VPC to be publicly accessible, you must enable the VPC attributes DNS hostnames and DNS resolution."

How do I change my RDS availability zone?

If your RDS is single instance and in the different AZ to your EC2 instance, you will need to take a snapshot and create the instance again in order to change the availability zone. modified my answer. you can have more reader end points .

Does AWS have access to my data in RDS?

Access Control Amazon RDS is integrated with AWS Identity and Access Management (IAM) and provides you the ability to control the actions that your AWS IAM users and groups can take on specific resources (e.g., DB Instances, DB Snapshots, DB Parameter Groups, DB Event Subscriptions, and DB Options Groups).


Video Answer


1 Answers

Whether the database is made publicly accessible or not is derived from the vpcSubnets prop which is of type ec2.SubnetSelection.

const instance = new rds.DatabaseInstance(this, 'Instance', {
  ... // other props
  vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC }
});

See https://github.com/aws/aws-cdk/blob/v1.62.0/packages/%40aws-cdk/aws-rds/lib/instance.ts#L315

like image 114
jogold Avatar answered Oct 13 '22 08:10

jogold