aws / aws/aws-cdk

(hotswap): We don't support attributes of the 'AWS::DynamoDB::GlobalTable' resource.

Open
#35,688 2 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/aws-dynamodb effort/medium feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

Currently if I try to watch my stack which includes nested stacks we get the following error:
`We don't support attributes of the 'AWS::DynamoDB::GlobalTable' resource.`

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Last Known Working CDK Library Version

_No response_

### Expected Behavior

cdk watch should work

### Current Behavior

When running cdk watch we get back the following error when a change is detected

⚠️ The --hotswap and --hotswap-fallback flags deliberately introduce CloudFormation drift to speed up deployments
⚠️ They should only be used for development - never use them for your production Stacks!

ExampleStack: deploying... [1/1]
Could not perform a hotswap deployment, because the CloudFormation template could not be resolved: We don't support attributes of the 'AWS::DynamoDB::GlobalTable' resource. This is a CDK limitation. Please report it at https://github.com/aws/aws-cdk/issues/new/choose

✅ ExampleStack (no changes)

### Reproduction Steps

```
import * as cdk from 'aws-cdk-lib';
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
import { Construct } from 'constructs';

class OtherNestedStack extends cdk.NestedStack {
table: dynamodb.TableV2;

constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);

// Create DynamoDB table
const table = new dynamodb.TableV2(this, 'ExampleTable1', {
tableName: 'example-table1',
partitionKey: {
name: 'id',
type: dynamodb.AttributeType.STRING,
},

removalPolicy: cdk.RemovalPolicy.DESTROY, // For demo purposes only
});

this.table = table;
}
}

class NestedStack extends cdk.NestedStack {
constructor(scope: Construct, id: string, table: dynamodb.TableV2, props?: cdk.StackProps) {
super(scope, id, props);

// Create Lambda function
const helloLambda = new lambda.Function(this, 'HelloLambda', {
runtime: lambda.Runtime.NODEJS_18_X,
handler: 'hello.handler',
code: lambda.Code.fromAsset('lambda'),
environment: {
TABLE_NAME: table.tableName,
},
});

// Grant Lambda permissions to read/write to DynamoDB table
table.grantReadWriteData(helloLambda);

// Create API Gateway
const api = new apigateway.RestApi(this, 'ExampleApi', {
restApiName: 'Example Service',
description: 'Example API with Lambda and DynamoDB',
});

// Create Lambda integration
const helloIntegration = new apigateway.LambdaIntegration(helloLambda, {
requestTemplates: { 'application/json': '{ "statusCode": "200" }' },
});

// Add GET method to API Gateway
api.root.addMethod('GET', helloIntegration);

// Output the API Gateway URL
new cdk.CfnOutput(this, 'ApiUrl', {
value: api.url,
description: 'API Gateway URL',
});
}
}

export class ExampleStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);

// Create DynamoDB table
const table = new dynamodb.TableV2(this, 'ExampleTable1', {
tableName: 'example-table1',
partitionKey: {
name: 'id',
type: dynamodb.AttributeType.STRING,
},

removalPolicy: cdk.RemovalPolicy.DESTROY, // For demo purposes only
});

new NestedStack(this, 'NestedStack1', table);

// Output the DynamoDB table name
new cdk.CfnOutput(this, 'TableName', {
value: table.tableName,
description: 'DynamoDB table name',
});
}
}

const app = new cdk.App();
new ExampleStack(app, 'ExampleStack', {
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION,
},
});
```

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### AWS CDK Library version (aws-cdk-lib)

2.219.0

### AWS CDK CLI version

2.1029.4 (build 09c0061)

### Node.js Version

22

### OS

MAC

### Language

TypeScript

### Language Version

typescript 5.9.3

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with the provided nested-stack TypeScript example using cdk watch and hotswap. Trace the hotswap template resolution that rejects AWS::DynamoDB::GlobalTable attributes; done means the example's change is handled without that limitation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.