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.38k stars 3.79k forks source link

CfnTagAssociation: Multiple resources created by Synth #29756

Open whatnick opened 3 months ago

whatnick commented 3 months ago

Describe the bug

Adding LakeFormation Tags via Python CDK to Glue Tables results in this error : Resource parameter must have exactly 1 resource specified but 2 were provided.

Expected Behavior

Tags are assigned correctly when CDK synthesizes the underlying cloudformation resource.

Current Behavior

Cloudformation Resource is synthesized with duplicate resources being attached to the LakeFormation TAG leading to failure in deployment.

Reproduction Steps

Create a tag association in a Stack using code similar to this. This results in a synthesized resource with 2 resources in the TAG which fails to deploy.

association = CfnTagAssociation( self, f"{tag}TagAssociation", lf_tags=[ CfnTagAssociation.LFTagPairProperty( catalog_id=Aws.ACCOUNT_ID, tag_key=f"{namespace}-{tag}", tag_values=[tag_value], ) ], resource=CfnTagAssociation.ResourceProperty( catalog={}, table=CfnTagAssociation.TableResourceProperty( catalog_id=Aws.ACCOUNT_ID, name=table_name, database_name=database.database_name, ), ), )

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.136.0 (build 94fd33b)

Framework Version

No response

Node.js Version

v18.14.2

OS

Ubuntu 22.04

Language

Python

Language Version

3.9.18

Other information

No response

danielfordfc commented 2 months ago

Is there a workaround for this at all? Our tooling is currently susceptible to this issue @whatnick @khushail

whatnick commented 2 months ago

My solution so far has been to remove and re-add the tag. Mutating the tag causes the above issue.

whatnick commented 1 month ago

Just noting that with this bug, creating new tables with Tags fails as well now.

khushail commented 4 weeks ago

Thanks for reporting this @whatnick . Checking the API docs, its not clear as what might be causing the error. Please create an issue with Cloudformation coverage roadmap or try reaching out to Cloudformation team through AWS Premium Support.