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.

Response limit of 4k for CloudFormation Custom Resources

See original GitHub issue

Using the AwsCustomResource construct to easily pass in SDK calls is very useful. Some service calls however have a large response body and lead to Response object is too long. in their CloudFormation response.

It would be nice to have a conditional to check for that and truncate, or more ideally, have a property to control what output goes into the response body, similar to how physicalResourceIdPath works.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
NukaCodycommented, Jan 6, 2022

This shamefully took me 11 attempts to get right so here’s a working example to save others that come across this

    const cr = new AwsCustomResource(this, "EC2InstancePrivateIPv6", {
      onCreate: {
        service: "EC2",
        action: "describeInstances",
        physicalResourceId: PhysicalResourceId.of(`${db.instanceId}-ipv6`),
        parameters: {
          InstanceIds: [db.instanceId],
        },
        outputPaths: ["Reservations.0.Instances.0.NetworkInterfaces.0.Ipv6Addresses.0.Ipv6Address"],
      },
      policy: AwsCustomResourcePolicy.fromSdkCalls({ resources: AwsCustomResourcePolicy.ANY_RESOURCE }),
    });

    const ipv6Address = cr.getResponseField("Reservations.0.Instances.0.NetworkInterfaces.0.Ipv6Addresses.0.Ipv6Address");
    new AaaaRecord(this, "IPv6Record", {
      zone: privateZone,
      recordName: "pg",
      target: RecordTarget.fromIpAddresses(ipv6Address),
    });

It turned out I was assuming the response would be return like an API call Reservations[0].Instances[0]...etc. Double check the lambda logs if you run across the response limit error and see how the data Is outputed

3reactions
dacortcommented, Apr 12, 2021

FYI, I ran into a similar error message but it was due to an error in my helm chart where the resulting error message was too big for Lambda to return. Looking at the Lambda logs showed the specific error message.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom resource response objects - AWS CloudFormation
The total size of the response body can't exceed 4096 bytes. The status value sent by the custom resource provider in response to...
Read more >
Custom resource response objects - Amazon CloudFormation
Learn about custom resource response objects in Amazon CloudFormation. ... The total size of the response body can't exceed 4096 bytes.
Read more >
Advanced Custom Resources with AWS CDK - Medium
In Part 1, we learned what AWS CloudFormation custom resources are and how to create a custom resource using the AWS CDK's AWSCustomResource ......
Read more >
@aws-cdk/custom-resources - npm
CloudFormation imposes a hard limit of 4096 bytes for custom resources response objects. If your API call returns an object that exceeds this ......
Read more >
CFN Custom Resources backed by Step Functions
It waits until it receives a response on a callback URL specified in the payload. In your CloudFormation template a Custom Resource is...
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