aws-cdk-lib: AwsCustomResource sometimes does not install dependencies correctly #28005
Labels
aws-cdk-lib
Related to the aws-cdk-lib package
bug
This issue is a bug.
closed-for-staleness
This issue was automatically closed because it hadn't received any attention in a while.
response-requested
Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Describe the bug
We use a custom resource to invoke a cloudfront invalidation, leveraging the
AwsCustomResource
construct to do so.Usually this works fine, but sometimes it fails due to a missing
@aws-sdk/client-cloudfront
error. In other words, there sometimes seems to be an issue with installing the AWS SDK.Expected Behavior
The custom resource should install the required AWS SDK dependencies and Just Work.
Current Behavior
Usually the invalidation works as expected, but it regularly fails with the below error:
Reproduction Steps
Below is the exact code for the custom resource that we are using.
We use this construct in conjunction with two BucketDeployments such that the invalidation is triggered after the distribution and bucket deployments have finished updating, like so:
Possible Solution
https://github.com/aws/aws-cdk/tree/main/packages/aws-cdk-lib/custom-resources
The manner in which AWS SDK dependencies are handled seems to be by installing the V2 SDK and then using an adapter.
I don't see why it needs to be so convoluted and brittle–at this point in time, using the V3 SDK directly seems like the sensible thing to do since they are pre-installed in the Lambda Runtime on Node ≥18 (ie installing them should not even be needed).
Additional Information/Context
No response
CDK CLI Version
2.90.0 (build 8c535e4)
Framework Version
No response
Node.js Version
18
OS
Linux
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: