diff --git a/resources/cdk/aurora_serverless_app/setup.ts b/resources/cdk/aurora_serverless_app/setup.ts index 75cec12020d..d36f3b6eba0 100644 --- a/resources/cdk/aurora_serverless_app/setup.ts +++ b/resources/cdk/aurora_serverless_app/setup.ts @@ -14,7 +14,7 @@ import 'source-map-support/register'; import {Construct} from "constructs"; import {App, CfnOutput, Duration, Stack, StackProps} from 'aws-cdk-lib'; import {Secret} from 'aws-cdk-lib/aws-secretsmanager'; -import {Credentials, DatabaseClusterEngine, ServerlessCluster} from "aws-cdk-lib/aws-rds"; +import {Credentials, DatabaseClusterEngine, DatabaseCluster, DatabaseInstance, ServerlessCluster} from "aws-cdk-lib/aws-rds"; export class SetupStack extends Stack { constructor(scope: Construct, id: string, props?: StackProps) { @@ -33,18 +33,29 @@ export class SetupStack extends Stack { }); const dbname = 'auroraappdb' - const cluster: ServerlessCluster = new ServerlessCluster(this, 'doc-example-aurora-app-cluster', { - engine: DatabaseClusterEngine.AURORA_MYSQL, + +// const cluster: ServerlessCluster = new ServerlessCluster(this, 'doc-example-aurora-app-cluster', { +// engine: DatabaseClusterEngine.AURORA_MYSQL, +// defaultDatabaseName: dbname, +// enableDataApi: true, +// scaling: {autoPause: Duration.minutes(0)}, +// credentials: Credentials.fromSecret(secret, username) +// }) + + const cluster: DatabaseCluster = new DatabaseCluster(this, 'doc-example-aurora-app-cluster', { + engine: DatabaseClusterEngine.AURORA_POSTGRESQL, defaultDatabaseName: dbname, enableDataApi: true, - scaling: {autoPause: Duration.minutes(0)}, + serverlessV2MinCapacity: 0.5, + serverlessV2MaxCapacity: 8, credentials: Credentials.fromSecret(secret, username) }) // Create outputs from the stack. These values are required by Amazon Relational // Database Service (Amazon RDS) Data Service to run SQL statements on the cluster. new CfnOutput(this, 'SecretArn', {value: secret.secretArn}) - new CfnOutput(this, 'ClusterArn', {value: cluster.clusterArn}) +// new CfnOutput(this, 'ClusterArn', {value: cluster.clusterArn}) + new CfnOutput(this, 'ClusterArn', {value: cluster.clusterResourceIdentifier}) new CfnOutput(this, 'DbName', {value: dbname}) } }