CDK Reference to already cdk created RDS Database Instance to add tags

64 Views Asked by At

I have a cdk created RDS cluster like below.

    this.rdsCluster = new DatabaseCluster(this, "MyRdsClusterId", {
      
      engine: DatabaseClusterEngine.auroraMysql({ version: AuroraMysqlEngineVersion.VER_2_11_4 }),
      credentials: Credentials.fromSecret(secret),
      clusterIdentifier: "MyRdsCluster", 
      defaultDatabaseName: "mydefaultDb",
      storageEncrypted: true,
      instanceProps: {
        instanceType: InstanceType.of(InstanceClass.BURSTABLE2, InstanceSize.SMALL),
        vpcSubnets: {
          subnetType: SubnetType.PUBLIC,
        },
        vpc: props.vpc,
      },
      removalPolicy: RemovalPolicy.RETAIN,
      storageEncryptionKey: storageKey,
    });

I have to add tags to rds writer instance alone. However, I am not able to add only to the instance. I am able to use Tags.of(this.rdsCluster).add() but this adds the tags to cluster, instances and rds subnet groups as well.

Upon checking, I see that option

  1. is there to import rds instance using attributes as per documentation. But this requires me to specify security groups and ports which I don't have.

  2. there is a feature request which is closed https://github.com/aws/aws-cdk/issues/7295 I think this should be re-opened

Question:

  1. Is there any way (at least by imports) to add tags only to my rds writer instance in this case?
0

There are 0 best solutions below