如何在 AWS CDK project/stack 中导入现有的 Aurora Serverless 集群?

How to import an existing Aurora Serverless cluster in a AWS CDK project/stack?

我需要“检测”Aurora Serverless 集群,以便在 AWS 云开发工具包项目中使用它。为了方便管理,必须在外部创建集群。

如何通过 ARN 或名称将现有的 Aurora Serverless 集群导入 AWS CDK 代码(类似于 Ec2.Vpc.fromLookup CDK 调用)?

可以使用静态 fromServerlessClusterAttributes 方法吗?

import * as cdk from '@aws-cdk/core';
import * as rds from '@aws-cdk/aws-rds';

export class AuroraServerlessStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const myServerlessCluster = rds.ServerlessCluster.fromServerlessClusterAttributes(
      this, "ExistingCluster", {
        clusterIdentifier: "cluster-id-for-existing-cluster"
      }
    )
  }
}