aws-cdk: (Construct): (Removing reference in another stack, is causing removal in original stack)

Describe the bug

I have a StringParameter in a Stack

RuleCreation = new StringParameter(this, "param-rule-creation", new StringParameterProps()
            {
                ParameterName = $"{DeploymentPrefix}-rulecreation",
                Description = "Rule Creation Enabled",
                StringValue = ruleCreation
            });

This is being used in another Construct in a NetworkLoadBalancedTaskImageOptions()
like this

 Secrets = new Dictionary<string, Secret> {
                        { "Logging:LogLevel:Default" ,Secret.FromSsmParameter(props.BaseResources.LogLevel) },
                        { "RuleCreation", Amazon.CDK.AWS.ECS.Secret.FromSsmParameter(props.BaseResources.RuleCreation) },

After it has been deployed, if I REMOVE the “RuleCreation” String Parameter from the “Secrets” dictionary and do a Cdk diff

It shows as it being removed from the Stack, even though it is still in the Stack. and hence I can not cdk deploy the change to remove, as the deploy of the Stack complains that I can not remove “RuleCreation” as it is used in the Construct.

Expected Behavior

I should be able to remove the “Secret” from the Construct, and it should remain in the Stack

Current Behavior

cdk diff/deploy attempts to remove the StringParameter from the Stack, when it should leave it

It should only have removed the reference in the Construct

Reproduction Steps

            {
                ParameterName = $"{DeploymentPrefix}-rulecreation",
                Description = "Rule Creation Enabled",
                StringValue = ruleCreation
            });

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

cdk 2.2.26

Framework Version

core 3.1

Node.js Version

16.15.0

OS

Windows

Language

.NET

Language Version

.net 3.1

Other information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

All good, ill see if I can follow your tip above, otherwise ill just drop the stacks and recreate, as I cant just remove the reference as it complains. There’s something subtle going on that I just don’t understand 😦

Thanks for the help.