aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.66k stars 3.92k forks source link

route53: private hosted zone is not tagged with 'aws:cloudformation:stack-name' tag upon creation #24287

Closed j4zzcat closed 5 months ago

j4zzcat commented 1 year ago

Describe the bug

When creating a PrivateHostedZone, the resource is created but it is not tagged with the aws:cloudformation:stack-name tag.

Expected Behavior

As any resource created with the CDK, a PrivateHostZone should be tagged with the aws:cloudformation:stack-name tag.

Current Behavior

Resource not tagged.

Reproduction Steps

...
val phz = PrivateHostedZone.Builder.create(app, "dummy-phz")
  .zoneName("foo.bar")
  .vpc(vpc)
  .build()
...

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.65.0 (build 5862f7a)

Framework Version

No response

Node.js Version

v19.6.1

OS

macOS 13.1

Language

Java

Language Version

No response

Other information

No response

khushail commented 1 year ago

Thanks @j4zzcat for reaching out. it would be great if you could clarify why you expect adding tags by AWS for the resources.

j4zzcat commented 1 year ago

All the other constructs I used so far added this tag - vpc, subnet, security group, route table, nat, ec2 instance, inbound resolver etc. With this tag, life's easy identifying resources of a particular stack.

khushail commented 1 year ago

Thanks for the response @j4zzcat . AFAIK, there are no default tags applied on resources. Tags are created by user via constructs in the app and once the code is synthesized, these are applied to all the AWS resources it deploys. Here is reference for the tags and how these can be implemented. Let me know if that helps clarify your question.

j4zzcat commented 1 year ago

I can only say that when I'm using CDK to create resources, the tag aws:cloudformation:stack-name is created on many of the resources, including, but not limited to, vpc, subnet, security group, route table, nat, ec2 instance and inbound resolver. Further, one cannot create tags prefixed with aws - and so doesn't it mean that it's being done by AWS code somewhere? perhaps on a lower level like CloudFormation? See also 7930.

khushail commented 1 year ago

@j4zzcat , I re-checked the documentations for resource tags, but I am not sure why tags are not created with PrivateHostedZone resource. I will reach out to internal team to get it sorted. Thank you for reporting this.

khushail commented 5 months ago

Hey @j4zzcat , here is a doc that details out how cloudformation support adding tags to hostedZone, ,tags are implemented through interface HostedZoneTagProperty , as detailed out in this article -https://docs.aws.amazon.com/cdk/api/v2/java/software/amazon/awscdk/services/route53/CfnHostedZone.html

 Example:

     // The code below shows an example of how to instantiate this type.
     // The values are placeholders you should change.
     import software.amazon.awscdk.services.route53.*;
     CfnHostedZone cfnHostedZone = CfnHostedZone.Builder.create(this, "MyCfnHostedZone")
             .hostedZoneConfig(HostedZoneConfigProperty.builder()
                     .comment("comment")
                     .build())
             .hostedZoneTags(List.of(HostedZoneTagProperty.builder()
                     .key("key")
                     .value("value")
                     .build()))
             .name("name")
             .queryLoggingConfig(QueryLoggingConfigProperty.builder()
                     .cloudWatchLogsLogGroupArn("cloudWatchLogsLogGroupArn")
                     .build())
             .vpcs(List.of(VPCProperty.builder()
                     .vpcId("vpcId")
                     .vpcRegion("vpcRegion")
                     .build()))
             .build();

Please let me know if this works for you!

github-actions[bot] commented 5 months ago

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.