aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.68k stars 3.93k forks source link

Cannot create Aurora serverless DB using CfnDBCluster #3608

Closed realharry closed 5 years ago

realharry commented 5 years ago

Call to new CfnDBCluster() with engineMode: 'serverless' fails on cdk deploy.

For example, here's an example code:

    const cluster = new rds.CfnDBCluster(this, dbId, {
      dbClusterIdentifier: dbId,
      databaseName: 'main-db',
      engine: 'aurora',
      engineMode: 'serverless',
      port: 5432,
      masterUsername: 'postgres',
      masterUserPassword: 'postgres',
      scalingConfiguration: {
        minCapacity: 2,
        maxCapacity: 32,
        autoPause: false,
      },
      dbSubnetGroupName: sgName,

(I tried various different combinations of engines (e.g., aurora vs aurora-postgresql) and engVersions, and paramGroupNames, etc. with consistent results. It fails to deploy.)

The error I get:

 0/3 | 3:54:12 PM | CREATE_IN_PROGRESS   | AWS::RDS::DBCluster | main-db-staging (maindbstaging)
 1/3 | 3:54:13 PM | CREATE_FAILED        | AWS::RDS::DBCluster | main-db-staging (maindbstaging) The engine mode serverless you requested is currently unavailable. (Service: AmazonRDS; Status Code: 400; Error Code: InvalidParameterValue; Request ID: 7c9e3e42-849f-451a-9da7-91d9f8899e8e)
    Rbi2RdsStack.createAuroraServerless (/Users/harry/Projects/devops/deploy/rbi2-rds/lib/rbi2-rds-stack.ts:43:21)
    \_ Rbi2RdsStack.init (/Users/harry/Projects/devops/deploy/rbi2-rds/lib/rbi2-rds-stack.ts:39:25)
    \_ new Rbi2RdsStack (/Users/harry/Projects/devops/deploy/rbi2-rds/lib/rbi2-rds-stack.ts:34:10)
    \_ Object.<anonymous> (/Users/harry/Projects/devops/deploy/rbi2-rds/bin/rbi2-rds.ts:13:1)
    \_ Module._compile (internal/modules/cjs/loader.js:701:30)
    \_ Module.m._compile (/Users/harry/Projects/devops/deploy/rbi2-rds/node_modules/ts-node/src/index.ts:473:23)
    \_ Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    \_ Object.require.extensions.(anonymous function) [as .ts] (/Users/harry/Projects/devops/deploy/rbi2-rds/node_modules/ts-node/src/index.ts:476:12)
    \_ Module.load (internal/modules/cjs/loader.js:600:32)
    \_ tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    \_ Function.Module._load (internal/modules/cjs/loader.js:531:3)
    \_ Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    \_ Object.<anonymous> (/Users/harry/Projects/devops/deploy/rbi2-rds/node_modules/ts-node/src/bin.ts:158:12)
    \_ Module._compile (internal/modules/cjs/loader.js:701:30)
    \_ Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    \_ Module.load (internal/modules/cjs/loader.js:600:32)
    \_ tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    \_ Function.Module._load (internal/modules/cjs/loader.js:531:3)
    \_ Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    \_ findNodeScript.then.existing (/usr/local/lib/node_modules/npm/node_modules/libnpx/index.js:268:14)

Anything that can be created via CloudFormation should be create-able using CDK, even with low level CFN constructs.

Documentation does not explicitly mention that aurora serverless cannot be created via CDK. https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-rds.CfnDBCluster.html

Likewise, CloudFormation doc does not state that it cannot create aurora serverless.

This is related to https://github.com/aws/aws-cdk/issues/929, which requests for a way to create Aurora Serverless using high-level RDS constructs.

Note: I tried it on various regions including us-west-1 and us-west-2 with the same results.

ApocDev commented 5 years ago

Serverless can be created with the cdk. See https://github.com/aws/aws-cdk/issues/929#issuecomment-516511171

Use the following: Engine: aurora Mode: serverless EngineVersion: 2.3

MinCapacity: 8 (required min)

When in doubt, always check the aws cli docs to see what valid values are. https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.create.html

realharry commented 5 years ago

Thanks, @ApocDev Yes, I think I had some mixups with regions and/or other params. I was finally able to deploy it on us-west-2.