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

(dynamodb): CfnGlobalTable is not taggable #26891

Closed
colifran opened this issue Aug 25, 2023 · 3 comments
Closed

(dynamodb): CfnGlobalTable is not taggable #26891

colifran opened this issue Aug 25, 2023 · 3 comments
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@colifran
Copy link
Contributor

Describe the bug

The GlobalTable L1 does not work with Tags because it does not implement the ITaggable interface.

Expected Behavior

Using Tags.of(...).add(...) should add tags to the resource and these should show up in the synthesized template.

Current Behavior

Tags.of(...).add(...) does not add Tags to the CfnGlobalTable resource - Tags are not rendered in the synthesized template.

As an example, this code:

const stack = new Stack(undefined, 'Stack', { env: { region: 'us-west-2' } });

  const globalTable = new CfnGlobalTable(stack, 'GlobalTable', {
    keySchema: [
      { attributeName: 'pk', keyType: 'HASH' },
    ],
    attributeDefinitions: [
      { attributeName: 'pk', attributeType: 'S' },
    ],
    replicas: [
      { region: 'us-west-2' },
      { region: 'us-east-1' },
    ],
  });
  Tags.of(globalTable).add('env', 'prod');

will produce the following template:

{
        "Resources": {
            "GlobalTable": {
                "Type": "AWS::DynamoDB::GlobalTable",
                "Properties": {
                    "AttributeDefinitions": [
                        {
                            "AttributeName": "pk",
                            "AttributeType": "S"
                        }
                    ],
                    "KeySchema": [
                        {
                            "AttributeName": "pk",
                            "KeyType": "HASH"
                        }
                    ],
                    "Replicas": [
                        {
                            "Region": "us-west-2"
                        },
                        {
                            "Region": "us-east-1"
                        }
                    ]
                }
            }
        },
        "Parameters": {
            "BootstrapVersion": {
                "Type": "AWS::SSM::Parameter::Value<String>",
                "Default": "/cdk-bootstrap/hnb659fds/version",
                "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
            }
        },
        "Rules": {
            "CheckBootstrapVersion": {
                "Assertions": [
                    {
                        "Assert": {
                            "Fn::Not": [
                                {
                                    "Fn::Contains": [
                                        [
                                            "1",
                                            "2",
                                            "3",
                                            "4",
                                            "5"
                                        ],
                                        {
                                            "Ref": "BootstrapVersion"
                                        }
                                    ]
                                }
                            ]
                        },
                        "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
                    }
                ]
            }
        }

Reproduction Steps

This can be reproduced with this code snippet also referenced above:

const stack = new Stack(undefined, 'Stack', { env: { region: 'us-west-2' } });

  const globalTable = new CfnGlobalTable(stack, 'GlobalTable', {
    keySchema: [
      { attributeName: 'pk', keyType: 'HASH' },
    ],
    attributeDefinitions: [
      { attributeName: 'pk', attributeType: 'S' },
    ],
    replicas: [
      { region: 'us-west-2' },
      { region: 'us-east-1' },
    ],
  });
  Tags.of(globalTable).add('env', 'prod');

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.93.0

Framework Version

No response

Node.js Version

v18.16.0

OS

Mac

Language

Typescript

Language Version

No response

Other information

No response

@colifran colifran added bug This issue is a bug. p1 labels Aug 25, 2023
@peterwoodworth peterwoodworth added the effort/small Small work item – less than a day of effort label Aug 25, 2023
@jumic
Copy link
Contributor

jumic commented Aug 26, 2023

CloudFormation allows tagging for DynamoDB tables (CfnTable), see documentation: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-tags

The CloudFormation resources for GlobalTables don't support tags. There's no tags attribute in the documentation: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-globaltable.html

In my opinion, this is the reason why CfnGlobalTable doesn't implement the ITaggable interface.

@scanlonp
Copy link
Contributor

scanlonp commented Nov 1, 2023

PR #27649 closes this issue.

@scanlonp scanlonp closed this as completed Nov 1, 2023
Copy link

github-actions bot commented Nov 1, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

No branches or pull requests

4 participants