'AWS CDK: Put Redshift cluster into existing subnet group

Environment: CDK 1.49.1, Typescript, Mac OS X

My AWS account comes with a Redshift subnet group preinstalled, let's assume it is called accountsetup-dirk-redshift-subnet-group

When using the Cluster construct, I try to pass in the subnet group:

    new redshift.Cluster(this, 
      `Cluster${this.stackName}`,
      {
        vpc: vpc,
...
        vpcSubnets: {subnetName: 'accountsetup-dirk-redshift-subnet-group'},

Running cdk synth returns:

There are no subnet groups with name 'accountsetup-dirk-redshift-subnet-group' in this VPC. Available names: Private

How can I put my new cluster into the existing subnet group?



Solution 1:[1]

You can achieve this for RDS by doing this given below

subnetGroup: rds.SubnetGroup.fromSubnetGroupName(this,'mysubnet','default')

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Abhishek Dutt