Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec2cdk: Breaking changes in Aws-cdk-lib-java from Tagging Change #29869

Closed
GavinZZ opened this issue Apr 17, 2024 · 2 comments · Fixed by #29870
Closed

spec2cdk: Breaking changes in Aws-cdk-lib-java from Tagging Change #29869

GavinZZ opened this issue Apr 17, 2024 · 2 comments · Fixed by #29870
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@GavinZZ
Copy link
Contributor

GavinZZ commented Apr 17, 2024

Describe the bug

#28989
This PR caused breaking change in aws-cdk-lib-java package since v2.136.0.

public class CdkJavaStack extends Stack {
    public CdkJavaStack(final Construct scope, final String id) {
        this(scope, id, null);
    }

    public CdkJavaStack(final Construct scope, final String id, final StackProps props) {
        super(scope, id, props);

        CfnVPC vpc = CfnVPC.Builder
            .create(this, "MyVpc")
            .enableDnsHostnames(true)
            .enableDnsSupport(true)
            .instanceTenancy("default")
            .build();

        List<CfnSubnet> subnets = new ArrayList<>();
        CfnSubnet subnet = new CfnSubnet(this,
            "PublicSubnets",
            CfnSubnetProps.builder()
                    .vpcId(vpc.getRef())
                    .mapPublicIpOnLaunch(false)
                    .tags(List.of(CfnTag.builder().key("MyKey").value("MyValue").build()))
                    .build());

        subnets.add(subnet);

        System.out.println(subnets.get(0).getTags().tagValues());
        String natGatewayName = subnets.get(0).getTags().tagValues().get("MyKey") + "-NatGateway";
        CfnNatGateway natGateway = CfnNatGateway.Builder
            .create(this, natGatewayName)
            .subnetId(subnets.get(0).getRef())
            .tags(List.of(CfnTag.builder().key("MyKey").value(natGatewayName).build()))
            .build();
    }
}

Expected Behavior

In cdk version v.120.0, the line String natGatewayName = subnets.get(0).getTags().tagValues().get("MyKey") + "-NatGateway"; will correctly generate the name.

Current Behavior

However, in v.136.0, this would result in Null-NateGateway. And it's causing breaking changes.

Reproduction Steps

See above template.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

v.136.0

Framework Version

No response

Node.js Version

20

OS

MacOS

Language

Java

Language Version

No response

Other information

No response

@GavinZZ GavinZZ added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 17, 2024
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Apr 17, 2024
@khushail khushail added effort/small Small work item – less than a day of effort p1 and removed needs-triage This issue or PR still needs to be triaged. labels Apr 17, 2024
@mergify mergify bot closed this as completed in #29870 Apr 17, 2024
mergify bot pushed a commit that referenced this issue Apr 17, 2024
### Issue # (if applicable)

Closes #29869

### Reason for this change

Without it, it breaks java users who rely on tagging name to generate resource id.

### Description of changes

Provide a default value using the initial `tagValue` users provide.

### Description of how you validated changes

Existing tests all pass. Essentially changing it back to the original state.

### Checklist
- [ ] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy link

⚠️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.

@aws-cdk-automation
Copy link
Collaborator

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants