question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[dms] Cfn lowercases the replicationSubnetGroupIdentifier on creation but CDK passes the same string without lowercasing.

See original GitHub issue

While using Cfn level constructs to generate a DMS solution, we had an issue with the replicationSubnetGroupIdentifier being implicitly lower-cased by CloudFormation but then when we referenced it elsewhere, CDK did not also lower-case the value.

Reproduction Steps

Set your stackName to something with mixed case.

    this.subnetGroup = new dms.CfnReplicationSubnetGroup(this, 'DmsSubnetGroup', {
      // If you might be mixing cases, you're going to want to force this to lowercase...
      replicationSubnetGroupIdentifier: `${scope.stackName}-subnet-group`,
      replicationSubnetGroupDescription: `${scope.stackName} Subnet Group`,
      subnetIds: scope.vpc.privateSubnets.map((s): string => {
        return s.subnetId;
      }),
    });
    new cdk.CfnOutput(this, 'TheDmsSubnetGroupArn', { value: this.subnetGroup.ref });

    this.instance = new dms.CfnReplicationInstance(this, 'Instance', {
      replicationInstanceIdentifier: `${scope.stackName}-lims-instance`,
      replicationInstanceClass: 'dms.t2.micro', // WRITEME: do we need this configurable?
      kmsKeyId: this.kmsKey.keyId,
      // Cfn will .toLowerCase this, and CDK won't do that for you.
      replicationSubnetGroupIdentifier: this.subnetGroup.replicationSubnetGroupIdentifier,
      vpcSecurityGroupIds: [sg.securityGroupId],
      publiclyAccessible: false,
    });
    this.instance.addDependsOn(this.subnetGroup);

What did you expect to happen?

I expected replicationSubnetGroupIdentifier: this.subnetGroup.replicationSubnetGroupIdentifier to provide a working reference.

What actually happened?

The SubnetGroup resource is created with all lower-case names. The Instance resource is passed a replicationSubnetGroupIdentifier with mixed case. The Instance resource then fails to create.

Environment

  • CDK CLI Version : 1.66.0
  • Framework Version: 1.66.0
  • Node.js Version: v14.3.0
  • OS: Darwin andrew-hammond-C02XKGFMJG5H-SM 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64
  • Language (Version): TypeScript (4.0.3)

This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
NetaNircommented, Nov 13, 2020

What you could do is use the subnetGroup Ref:

    this.instance = new dms.CfnReplicationInstance(this, 'Instance', {
      replicationInstanceIdentifier: `${scope.stackName}-lims-instance`,
      replicationInstanceClass: 'dms.t2.micro',
      // Cfn will .toLowerCase this, and CDK won't do that for you.
      replicationSubnetGroupIdentifier: this.subnetGroup.ref,
      vpcSecurityGroupIds: [sg.securityGroupId],
      publiclyAccessible: false,
    });

The Ref is a value resolved by CloudFormation at deploy time, from DMS docs:

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the name of the replication subnet group, such as mystack-myrepsubnetgroup-0a12bc456789de0fg.

Using Ref will also implicitly create the dependency between the subnetGroup and the instance, so you remove the line that adds it explicitly:

this.instance.addDependsOn(this.subnetGroup);
0reactions
github-actions[bot]commented, Nov 16, 2020

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A VPC associated with the ReplicationSubnetGroup does not ...
... Cfn lowercases the ReplicationSubnetGroupIdentifier (dms-subnetgroupdemo) on creation as shown below but CDK passes the same string ...
Read more >
class CfnReplicationInstance (construct) · AWS CDK
This parameter is stored as a lowercase string. replicationSubnetGroupIdentifier? string, A subnet group to associate with the replication instance.
Read more >
A VPC associated with the ReplicationSubnetGroup does not exist ...
... Cfn lowercases the ReplicationSubnetGroupIdentifier (dms-subnetgroupdemo) on creation as shown below but CDK passes the same string without lowercasing.
Read more >
Creating an AWS DMS task using AWS CDK - Stack Overflow
There are no CDK constructs to simplify working with DMS. Therefore you'll have to use the CloudFormation resources: CfnEndpoint, ...
Read more >
awsdms - Go Packages
import dms "github.com/aws/aws-cdk-go/awscdk" ... Construct, id *string, . ... If you pass CDK classes or structs, they will be // rendered with lowercased...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found