问题描述
对于AWS RDS,控制台和CLI/API都具有使数据库可公开访问的开关,但是我找不到使用提供的结构通过新的aws-cdk做到这一点的方法.在Cloud Formation类(例如CfnDBInstance)中有一个布尔值,但是我找不到有关如何将其与结构结合使用的文档. CDK非常令人惊叹,除了这一段代码外,它只需几行代码就可以完美地设置所有内容.
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.
推荐答案
是否使数据库可公开访问是源自类型为ec2.SubnetSelection
的vpcPlacement
属性.
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 }
});
请参见 https://github.com/aws/aws-cdk/blob/v1.3.0/packages/%40aws-cdk/aws-rds/lib/instance.ts#L529
这篇关于在aws-cdk上的aws-rds上,可公开访问数据库的设置在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!