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

CfnTagAssociation: Multiple resources created by Synth #29756

Open
whatnick opened this issue Apr 8, 2024 · 5 comments
Open

CfnTagAssociation: Multiple resources created by Synth #29756

whatnick opened this issue Apr 8, 2024 · 5 comments
Labels
@aws-cdk/aws-lakeformation Related to AWS Lake Formation bug This issue is a bug. effort/small Small work item – less than a day of effort needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p3 package/tools Related to AWS CDK Tools or CLI

Comments

@whatnick
Copy link

whatnick commented Apr 8, 2024

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

@whatnick whatnick added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 8, 2024
@github-actions github-actions bot added the @aws-cdk/aws-lakeformation Related to AWS Lake Formation label Apr 8, 2024
@whatnick whatnick changed the title (module name): (short issue description) CfnTagAssociation: Multiple resources created by Synth Apr 8, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Apr 8, 2024
@khushail khushail added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Apr 8, 2024
@khushail khushail self-assigned this Apr 8, 2024
@khushail khushail removed the needs-triage This issue or PR still needs to be triaged. label Apr 8, 2024
@danielfordfc
Copy link

danielfordfc commented Apr 25, 2024

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

@whatnick
Copy link
Author

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

@khushail khushail added p2 effort/small Small work item – less than a day of effort labels Apr 26, 2024
@pahud pahud added p3 and removed p2 labels Jun 11, 2024
@whatnick
Copy link
Author

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

@khushail khushail added the needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. label Jun 17, 2024
@khushail
Copy link
Contributor

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.

@khushail khushail removed the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Jun 17, 2024
@khushail khushail removed their assignment Jun 17, 2024
@whatnick
Copy link
Author

whatnick commented Aug 6, 2024

So the error seems to stem from both catalog and table keys being specified in the synthesized Cfn template from the sample code. The API from cloudformation creating the resource in Lake Formation cannot handle that specification after a given update and the whole thing gets stuck if there is an old template with the extra catalog entry there.

"Resource": {
          "Catalog": {},
          "Table": {
            "CatalogId": {
              "Ref": "AWS::AccountId"
            },
            "DatabaseName": {
              "Ref": "SomeDB"
            },
            "Name": "some-table-name"
          }
        }

The solution is to :

  • Clean up all tags by updating the Template. Using retain on the underlying resource if the tags are in live use for security purposes in an underlying system.
  • Create new TagAssociations with only one Catalog, Table or Database resource. Previous CloudFormation allowed multiple resources to be specified and this is now tangled and needs manual untangling.

From a CDK perspective, I can suggest that Synth fails if :

  • Multiple items are speficied in the resource.
  • Any nulls like an empty catalog dict are dropped to avoid confusion at the CloudFormation end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lakeformation Related to AWS Lake Formation bug This issue is a bug. effort/small Small work item – less than a day of effort needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p3 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests

4 participants