Skip to content

Commit

Permalink
chore: document reason and mitigation for cross region reference fail…
Browse files Browse the repository at this point in the history
…ure from response objects being too large (#30115)

### Issue

#23958, #25114

### Reason for this change

Using the `crossRegionReference` flag on `StackProps` can produce deployment errors associated with response objects being too large. The root cause of this is a CloudFormation limitation that restricts the total size of a custom resource provider response body to [4096 bytes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-responses.html). Using `crossRegionReference` will create a custom resource in both the producing stack and the consuming stack. The custom resource provider in the producing stack will respond back to CloudFormation with a response object that includes all exported parameter names and values. Similarly, the consuming stack will respond back to CloudFormation with a response object that includes all imported parameter names and values. The parameter names are created with the following naming format: `/cdk/exports/${consumingStackName}/${export-name}`. Users need to be careful about stack names and the use of nested stacks to limit the overall length of parameter names which will limit the size of the response body. This PR adds documentation to give more context about this issue and ways to help mitigate it.

### Description of changes

Added documentation.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
colifran committed May 9, 2024
1 parent 2779b5e commit 9def360
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/aws-cdk-lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,15 @@ In order to mimic strong references, a Custom Resource is also created in the co
stack which marks the SSM parameters as being "imported". When a parameter has been successfully
imported, the producing stack cannot update the value.

See the [adr](https://github.com/aws/aws-cdk/blob/main/packages/@aws-cdk/core/adr/cross-region-stack-references)
> [!NOTE]
> As a consequence of this feature being built on a Custom Resource, we are restricted to a
> CloudFormation response body size limitation of [4096 bytes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-responses.html).
> To prevent deployment errors related to the Custom Resource Provider response body being too
> large, we recommend limiting the use of nested stacks and minimizing the length of stack names.
> Doing this will prevent SSM parameter names from becoming too long which will reduce the size of the
> response body.
See the [adr](https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/core/adr/cross-region-stack-references.md)
for more details on this feature.

### Removing automatic cross-stack references
Expand Down

0 comments on commit 9def360

Please sign in to comment.