Skip to content
New issue

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

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

Already on GitHub? # to your account

(dynamodb): Dynamo TableV2 does not work with Tags.of #30631

Closed
ckuehne opened this issue Jun 23, 2024 · 7 comments · Fixed by #31867
Closed

(dynamodb): Dynamo TableV2 does not work with Tags.of #30631

ckuehne opened this issue Jun 23, 2024 · 7 comments · Fixed by #31867
Assignees
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@ckuehne
Copy link

ckuehne commented Jun 23, 2024

Describe the bug

The aws_dynamodb.TableV2 construct does not support adding tags via Tags.of.

I.e., the following code does not create the myKey tag.

import * as cdk from 'aws-cdk-lib';
import {aws_dynamodb, Tags} from "aws-cdk-lib";

const app = new cdk.App();
const stack = new cdk.Stack(app, 'Stack');

const globalTable = new aws_dynamodb.TableV2(stack, 'GlobalTable', {
    partitionKey: {name: 'pk', type: aws_dynamodb.AttributeType.STRING},
});

Tags.of(globalTable).add('myKey', 'myValue');

Expected Behavior

Creates tag.

Current Behavior

Does not create tag.

Reproduction Steps

import * as cdk from 'aws-cdk-lib';
import {aws_dynamodb, Tags} from "aws-cdk-lib";

const app = new cdk.App();
const stack = new cdk.Stack(app, 'Stack');

const globalTable = new aws_dynamodb.TableV2(stack, 'GlobalTable', {
    partitionKey: {name: 'pk', type: aws_dynamodb.AttributeType.STRING},
});

Tags.of(globalTable).add('myKey', 'myValue');

cdk synth

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.147.0 (build 3338fc0)

Framework Version

No response

Node.js Version

v20.3.1

OS

Macos

Language

TypeScript

Language Version

TypeScript 5.4.5

Other information

No response

@ckuehne ckuehne added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 23, 2024
@github-actions github-actions bot added the @aws-cdk/aws-dynamodb Related to Amazon DynamoDB label Jun 23, 2024
@TirushV
Copy link

TirushV commented Jun 23, 2024

Suggestion: Try using aspects to add tags to the current stack where Aspect is called.

@ckuehne
Copy link
Author

ckuehne commented Jun 23, 2024

Suggestion: Try using aspects to add tags to the current stack where Aspect is called.

Yes, this would work. But still the buggy behaviour is unexpected and should be fixed.

@TirushV
Copy link

TirushV commented Jun 23, 2024

Thats true. I agree with you.

I had this use case before and solved it by getting the all event notification first inside a list and then recreating then along with new one again. (Temporary solution) XD

@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Jun 24, 2024
@khushail
Copy link
Contributor

khushail commented Jun 24, 2024

Hey @ckuehne , thanks for reporting this. I reproduced this issue and agree that this is a buggy behavior. Hence marking it as P3.

However if you try assigning the tags like this, this adds the tags to the table. Usage of ASPECTS (sample code) would also be another workaround

    const globalTable = new aws_dynamodb.TableV2(this, 'GlobalTable', {
      partitionKey: {name: 'pk', type: aws_dynamodb.AttributeType.STRING},
      tags: [{key: "myKeyTag", value: "myValueTag"}]
    });
 

@khushail khushail added p3 p2 effort/small Small work item – less than a day of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. p3 labels Jun 24, 2024
@5d 5d self-assigned this Oct 23, 2024
@5d
Copy link
Contributor

5d commented Oct 28, 2024

Hi @ckuehne ,

I have a quick question: when you write code like Tags.of(globalTable).add('myKey', 'myValue');, do you intend for the tag to apply only to the default replica, or to all replicas of the global table?

@mergify mergify bot closed this as completed in #31867 Nov 2, 2024
@mergify mergify bot closed this as completed in 796c6d1 Nov 2, 2024
Copy link

github-actions bot commented Nov 2, 2024

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.

1 similar comment
Copy link

github-actions bot commented Nov 2, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 2, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants