Amazon web services 如何在CDK中创建Aurora无服务器数据库
我正在尝试建立一个aurora无服务器数据库。在控制台中,它很简单,我只使用默认的子网组,一切都很好 但是,当我使用cdk时,会出现错误“Aurora Serverless不支持子网位于同一可用性区域的DB子网组。请选择子网位于不同可用性区域的DB子网组。”。我已经尝试过故障排除,但我真的不明白为什么它失败了,我想它使用的默认子网与我手动操作时使用的相同(而且它工作正常)?那么,为什么在使用cdk时突然出现了所有错误Amazon web services 如何在CDK中创建Aurora无服务器数据库,amazon-web-services,aws-cdk,aws-aurora-serverless,Amazon Web Services,Aws Cdk,Aws Aurora Serverless,我正在尝试建立一个aurora无服务器数据库。在控制台中,它很简单,我只使用默认的子网组,一切都很好 但是,当我使用cdk时,会出现错误“Aurora Serverless不支持子网位于同一可用性区域的DB子网组。请选择子网位于不同可用性区域的DB子网组。”。我已经尝试过故障排除,但我真的不明白为什么它失败了,我想它使用的默认子网与我手动操作时使用的相同(而且它工作正常)?那么,为什么在使用cdk时突然出现了所有错误 const auroraDatabaseCluster = new rds.S
const auroraDatabaseCluster = new rds.ServerlessCluster(this, 'Database', {
engine: rds.DatabaseClusterEngine.AURORA_POSTGRESQL,
credentials: rds.Credentials.fromSecret(masterSecret),
parameterGroup: clusterParameterGroup,
defaultDatabaseName: databaseName,
vpc: vpc,
securityGroups: [databaseSecurityGroup],
storageEncryptionKey: databaseKey,
deletionProtection: false
});
有人知道怎么回事吗
我还可以使用区域极光数据库让它工作
const auroraDatabaseCluster = new rds.DatabaseCluster(this, 'Database', {
engine: rds.DatabaseClusterEngine.auroraPostgres({version: rds.AuroraPostgresEngineVersion.VER_11_8}),
instances: 2, // TODO should be 2
credentials: rds.Credentials.fromSecret(masterSecret),
defaultDatabaseName: databaseName,
port: endpointPort,
storageEncrypted: true,
storageEncryptionKey: databaseKey,
deletionProtection: false, // TODO enable in prod
parameterGroup: clusterParameterGroup,
instanceProps: {
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.MEDIUM),
securityGroups: [databaseSecurityGroup],
vpcSubnets: {
subnetType: ec2.SubnetType.PRIVATE,
},
vpc,
},
});
我通过手动添加onePerAZ=true的DB securityGroup解决了这个问题
const subnetGroup = new rds.SubnetGroup(this, "subnetGroup", {
description: `Subnetgroup for serverless postgres aurora databasa`,
vpc: vpc,
vpcSubnets: {onePerAz: true},
})
const auroraDatabaseCluster = new rds.ServerlessCluster(this, 'Database', {
engine: rds.DatabaseClusterEngine.AURORA_POSTGRESQL,
credentials: rds.Credentials.fromSecret(masterSecret),
parameterGroup: clusterParameterGroup,
defaultDatabaseName: databaseName,
vpc: vpc,
subnetGroup: subnetGroup,
securityGroups: [databaseSecurityGroup],
storageEncryptionKey: databaseKey,
deletionProtection: false
});