Closed antoncohen closed 5 months ago
Hi @antoncohen , stack names in AWS CDK have a maximum length of 128 characters. It might be better to have a look at name length to rule it out.
Hi @antoncohen , stack names in AWS CDK have a maximum length of 128 characters. It might be better to have a look at name length to rule it out.
It isn't a general stack name length issue, as far as I can tell. You can see the stack name in the error message and reproduction example code. The longest stack name is 83 characters.
Everything is created fine in the primary region (cross-region writer), it only fails in the replica region (cross-region reader). And if the NUMBER_OF_KEYS_TO_CREATE
constant is changed to 8 or less it works. The stacks work. The cross-region references are what is failing when NUMBER_OF_KEYS_TO_CREATE
is 9 or more.
We likely need a similar fix like this one that was abandoned. The issue is likely that the response in the custom resource handler is too long (over 4096 bytes)
running into this bug as well, what @peterwoodworth mentioned sounds right, when I look at the custom resource handler cloudwatch logs I don't see any errors, but the response object looks like it is likely over 4096 bytes. maybe we can store the response object in an s3 bucket and then just return a reference to the object in s3.
This behavior prevents me from being able to deploy to more regions and thus prevents me from spending more money on aws ;)
This is a CloudFormation limitation stemming from custom resource provider responses being limited to 4096 bytes - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-responses.html. In the specific use case you've provided you can fix this by shortening the overall stack name by either shortening the stack prefix or by not using nested stacks which is adding to the stack name length. Longer term I'm not sure there is a good alternative here. We can't truncate or provide something like outputPaths
since all of the imports are needed in the export reader response back to CloudFormation since the import of the exported values takes place using a getAtt
: https://github.com/aws/aws-cdk/blob/2c53cf959d4de8a2d7cadfb24985087df1199305/packages/aws-cdk-lib/core/lib/custom-resource-provider/cross-region-export-providers/export-reader-provider.ts#L86-L89
Added documentation for this here and opened a new issue to track this for crossRegionReferences
as a whole - https://github.com/aws/aws-cdk/issues/30119
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Describe the bug
When using
crossRegionReferences: true
thecdk deploy
fails in the reader region withResponse object is too long
.Similar to #23958, but on the reader side, likely with a different root cause.
Expected Behavior
I expect
crossRegionReferences: true
to work, and it be possible to reference variables across stacks in different regions.Current Behavior
When referencing a variable in a stack in a different region, it fails in the reader region with this error:
This is using Nested Stacks, and long stack names, with multiple cross-region references.
Reproduction Steps
Node.js: 18.15.0 CDK bin and lib: 2.73.0 TypeScript: 5.0.4 Command:
npx cdk deploy --all --require-approval=never --verbose --debug --app 'npx ts-node app.ts'
app.ts:
At the top of
app.ts
the constantACCOUNT_ID
will need to be changed. The constantNUMBER_OF_KEYS_TO_CREATE
can be lowered below 9 to not trigger the error.I don't see any errors in the Lambda logs. Parameter Store values are written. And in the reader region the Parameter Store tags are set and removed, according to the Lambda logs.
Possible Solution
My guess is that it is triggered long stack names, including nested stacks creating even longer reference names.
Additional Information/Context
No response
CDK CLI Version
2.73.0 (build 43e681e)
Framework Version
No response
Node.js Version
18.15.0
OS
macOS
Language
Typescript
Language Version
TypeScript (5.0.4)
Other information
No response