question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DynamoDB: Creation of Global table with CDK 1.77.0 Fails

See original GitHub issue

Updating 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
oscar-delacommented, Nov 29, 2022

Same here. I also encounter same error as @OliverLonghi described.

1reaction
kbroniekcommented, Jan 26, 2021

@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:

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

        const testTableDynamoDb = new Table(this, "TestTable", {
            partitionKey: { name: "id", type: AttributeType.STRING },
            encryption: TableEncryption.AWS_MANAGED,
            replicationRegions: replicationRegions,
            billingMode: BillingMode.PROVISIONED,
            readCapacity: 5,
            writeCapacity: 1,
        });

        testTableDynamoDb
            .autoScaleReadCapacity({ minCapacity: 5, maxCapacity: 10 })
            .scaleOnUtilization({ targetUtilizationPercent: 75 });
        testTableDynamoDb
            .autoScaleWriteCapacity({ minCapacity: 1, maxCapacity: 10 })
            .scaleOnUtilization({ targetUtilizationPercent: 75 });
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

aws-cdk/aws-dynamodb module - AWS Documentation
Amazon DynamoDB Global Tables ... You can create DynamoDB Global Tables by setting the replicationRegions property on a Table : const globalTable =...
Read more >
aws-cdk.aws-dynamodb-global - PyPI
Creates a DynamoDB table in a separate stack in each DynamoDBGlobalStackProps.region specified · Deploys a CFN Custom Resource to your stack's specified region ......
Read more >
Amazon.CDK.AWS.DynamoDB.Global 1.50.0 - NuGet
Version Downloads Last updated 1.183.0 52 6 days ago 1.182.0 69 13 days ago 1.181.1 83 22 days ago
Read more >
@aws-cdk/aws-dynamodb | Yarn - Package Manager
All user data stored in Amazon DynamoDB is fully encrypted at rest. When creating a new table, you can choose to encrypt using...
Read more >
aws-cdk/aws-stepfunctions/README.md - UNPKG
The CDN for @aws-cdk/aws-stepfunctions. ... Pass(this, 'Add Hello World', { ... the `DynamoDB` service integration to insert data into a DynamoDB table.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found