【问题标题】:unable to provision postgres12 database cluster using the AWS CDK无法使用 AWS CDK 预置 postgres12 数据库集群
【发布时间】:2021-07-08 21:35:43
【问题描述】:

给出以下代码:


// please note I created a wrapper around the cdk components, hence cdk.ec2 etc.

const vpc = new cdk.ec2.Vpc(this, `${appName}VPC`);
    const dbCredentials = cdk.rds.Credentials.fromGeneratedSecret('postgres');

    const engine = cdk.rds.DatabaseClusterEngine.auroraPostgres({ version: cdk.rds.PostgresEngineVersion.VER_12_6 });
    const parameterGroup = cdk.rds.ParameterGroup.fromParameterGroupName(this, 'ParameterGroup', 'default.aurora-postgresql12');

    // Create the Serverless Aurora DB cluster; set the engine to Postgres
    const dbcluster = new cdk.rds.DatabaseCluster(this, `${appName}Cluster`, {
      engine,
      parameterGroup,
      defaultDatabaseName: `${appName}DB`,
      credentials: dbCredentials,
      instanceProps: {
        instanceType: cdk.ec2.InstanceType.of(cdk.ec2.InstanceClass.R5, cdk.ec2.InstanceSize.LARGE),
        vpc,
        vpcSubnets: {
          subnetType: cdk.ec2.SubnetType.PUBLIC
        },
        publiclyAccessible: true,
        scaling: { autoPause: cdk.core.Duration.seconds(600) } // Optional. If not set, then instance will pause after 5 minutes
      }
    });

如果我们使用 postgres11 - 此代码可以正常工作,当我尝试安装 12 时,我收到 CDK 报告的以下错误:

带有 DBParameterGroupFamily aurora-postgresql12 的参数组 default.aurora-postgresql12 不能用于此实例。请使用参数 er 具有 DBParameterGroupFamily aurora-postgresql11 的组(服务:AmazonRDS;状态代码:400;错误代码:InvalidParameterCombination;请求 ID:e e90210d-070d-4593-9564-813b6fd4e331;代理:空)

我已经尝试了 instanceType 的大量组合(其中大部分在控制台上的 RDS UI 中工作) - 但我似乎无法安装 postgres12 - 知道我做错了什么吗?

也试过了:

const vpc = new cdk.ec2.Vpc(this, `${appName}VPC`);
    const dbCredentials = cdk.rds.Credentials.fromGeneratedSecret('postgres');
//DEFINING VERSION 12.6 FOR ENGINE
    const engine = cdk.rds.DatabaseClusterEngine.auroraPostgres({ version: cdk.rds.PostgresEngineVersion.VER_12_6 });
//DEFINING 11 FOR PARAMETER GROUP
    const parameterGroup = cdk.rds.ParameterGroup.fromParameterGroupName(this, 'ParameterGroup', 'default.aurora-postgresql11');

    const dbcluster = new cdk.rds.DatabaseCluster(this, `${appName}Cluster`, {
      engine,
      parameterGroup,
      defaultDatabaseName: `${appName}DB`,
      credentials: dbCredentials,
      instanceProps: {
        instanceType: cdk.ec2.InstanceType.of(cdk.ec2.InstanceClass.R6G, cdk.ec2.InstanceSize.LARGE),
        vpc,
        vpcSubnets: {
          subnetType: cdk.ec2.SubnetType.PUBLIC
        },
        publiclyAccessible: true,
        scaling: { autoPause: cdk.core.Duration.seconds(600) } // Optional. If not set, then instance will pause after 5 minutes
      }
    });

像梦一样工作 - 但安装引擎 v11.9 :( - 我需要 >12 因为我需要安装 pg_partman 沿线某处发动机不是。正确设置 - 或硬编码为 11

【问题讨论】:

    标签: postgresql amazon-web-services aws-cdk


    【解决方案1】:

    这对我有用:

    const AURORA_POSTGRES_ENGINE_VERSION = AuroraPostgresEngineVersion.VER_10_7
    const RDS_MAJOR_VERSION = AURORA_POSTGRES_ENGINE_VERSION.auroraPostgresMajorVersion.split('.')[0]
    
    const parameterGroup = ParameterGroup.fromParameterGroupName(
      scope,
      `DBPrameterGroup`,
      `default.aurora-postgresql${RDS_MAJOR_VERSION}`,
    )
    
    new ServerlessCluster(scope, `Aurora${id}`, {
      engine: DatabaseClusterEngine.auroraPostgres({
        version: AURORA_POSTGRES_ENGINE_VERSION,
      }),
      parameterGroup,
      defaultDatabaseName: DATABASE_NAME,
      credentials: {
        username: 'x',
      },
      vpc: this.vpc,
      vpcSubnets: this.subnetSelection,
      securityGroups: [securityGroup],
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-03
      • 2020-10-06
      • 2021-01-30
      • 1970-01-01
      • 2021-06-08
      • 2021-11-12
      相关资源
      最近更新 更多