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

大憨熊 提交于 2020-06-14 06:28:09

问题


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.


回答1:


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

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

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




回答2:


For the python crowd:

database = rds.DatabaseInstance(self, "Instance", 
        ... // other props
            vpc_placement=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PUBLIC),
        )


来源:https://stackoverflow.com/questions/57221125/on-aws-rds-on-aws-cdk-where-is-the-setting-to-make-database-publicly-accessible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!