【问题标题】:How to Make Aurora Serverless database in CDK如何在 CDK 中制作 Aurora Serverless 数据库
【发布时间】:2021-08-19 18:37:12
【问题描述】:

我正在尝试制作一个极光无服务器数据库。在控制台中它很简单,我只使用默认子网组,一切都很好。

但是,当我使用 cdk 时,我收到错误消息“Aurora Serverless 不支持具有相同可用区中子网的数据库子网组。请选择具有不同可用区中子网的数据库子网组。”。我试图排除故障,但我真的不明白为什么它会失败,我猜它使用与我手动执行时相同的默认子网(并且它有效)?那为什么用cdk的时候突然全错了...

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,
    },
  });

【问题讨论】:

    标签: amazon-web-services aws-cdk aws-aurora-serverless


    【解决方案1】:

    我通过使用 onePerAZ=true 手动添加数据库安全组解决了这个问题

    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
      });
    

    【讨论】:

      猜你喜欢
      • 2021-02-22
      • 2020-10-16
      • 2023-02-10
      • 2022-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多