DynamoDB: Creation of Global table with CDK 1.77.0 Fails
See original GitHub issueUpdating a DynamoDB table (us-east-1) to create a global table fails with the following error in the CloudFormation console: Response is not valid JSON
Reproduction Steps
config.secondaryRegion = 'us-west-1'
const tableKey = {
partitionKey: {
name: 'PK',
type: dynamodb.AttributeType.STRING
},
sortKey: {
name: 'SK',
type: dynamodb.AttributeType.STRING
}
}
const table = new dynamodb.Table(this, config.tableId, {
tableName: config.tableName,
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
replicationRegions: [config.secondaryRegion],
removalPolicy: cdk.RemovalPolicy.RETAIN,
...tableKey
})
What did you expect to happen?
DynamoDB table should have streams enabled and a replica of the table should be created in the specified region (us-west-1)
What actually happened?
Received the following error in CloudFormation console: Response is not valid JSON
Environment
- CDK CLI Version: 1.77.0 (build a941c53)
- Framework Version: 1.77.0
- Node.js Version: v12.18.3
- OS: Ubuntu 16.04. 7 LTS (Xenial Xerus)
- Language (Version): TypeScript (4.0.3)
Other
Contacted AWS Premium Support and got the following response:
To investigate the issue, I checked the Cloudformation stack “api-resources-v1-develop/43d62400-8604-11ea-b128-0eba1c1b0c34” and that shows custom resource ‘apiresourcesauthconfigv1developReplicauswest150E65633’ failed to respond to CloudFormation with a valid JSON response. Please understand custom resource in CDK is outside of the scope of AWS Support and thus we will not be able to help you troubleshoot the same.
However, in order to fix this issue I would suggest you to print the variable responsible for sending the response back to CloudFormation to the output first before sending the response to CloudFormation. This way you will be able to see exactly why the response data is not in a valid JSON format. In order to read more about this, please check these[1][2][3] documentation and examples.
I hope this email helps. Should you have any additional queries , please feel free to write back and I will be happy to help further! Hope you have a good day.
== References == [1] https://docs.aws.amazon.com/lambda/latest/dg/services-cloudformation.html [2] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-lambda-function-code-cfnresponsemodule.html [3] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html
We value your feedback. Please share your experience by rating this correspondence using the AWS Support Center link at the end of this correspondence. Each correspondence can also be rated by selecting the stars in top right corner of each correspondence within the AWS Support Center.
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:19 (7 by maintainers)
Same here. I also encounter same error as @OliverLonghi described.
@skinny85 I had the same issue. I created a new global table on us-east-1 and replicated it on eu-central-1. I have 3 environments and in two of them it deployed successfully but in one environment it failed during creating the replication. I had the same error
Response is not valid JSON
. But when I repeated the deployment, I haven’t seen any issue. It was weird and would be good to solve this issue. I use CDK version 1.80.0. This is what I use: