Documentation says to exclude @aws-sdk/* when bundling using the CDK. Should it?
#5044
-
|
Hello! Looking at the documentation here, it says to exclude I took a look at the contents of the layer published, and whilst some of the @aws-sdk packages are present, not all are. This then causes the function to fallback to whatever version of the SDK is present in the runtime. The question I have is "is there something obvious I've missed here, or does the documentation need updating?" |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Taken at face value the docs are technically incorrect - they do say the packages "are already present in the layer" when only 5 specific ones actually are. Fair point! However, the recommendation to exclude The Powertools utilities use their own AWS SDK modules from the layer, and mixing those with bundled versions can cause runtime issues. For any AWS SDK clients not in the layer or your bundle, Lambda falls back to the runtime's built-in SDK. So while the wording could be clearer (and we should fix that), the guidance is there to prevent dependency conflicts rather than just avoiding redundant packages. |
Beta Was this translation helpful? Give feedback.
Taken at face value the docs are technically incorrect - they do say the packages "are already present in the layer" when only 5 specific ones actually are. Fair point!
However, the recommendation to exclude
@aws-sdk/*is still correct for practical reasons. The AWS SDK has a deeply interconnected dependency tree - even if we only excluded the 5-6 top-level modules we bundle, you'd still get duplicates in shared modules like credential resolvers, signature helpers, etc. This creates version conflicts and bloats your bundle.The Powertools utilities use their own AWS SDK modules from the layer, and mixing those with bundled versions can cause runtime issues. For any AWS SDK clients not in …