New plan for AWS SDK v3#188
Merged
Merged
Conversation
This was referenced Apr 27, 2026
There was a problem hiding this comment.
Pull request overview
This PR removes the AWS SDK v3 “v2-style request shim” (command/client maps + SLS_AWS_SDK_V3 mode switch) and establishes a new plugin-facing foundation API for using AWS SDK v3 directly via provider.getAwsSdkV3Config(), while keeping core/internal AWS calls on the AWS SDK v2 request path.
Changes:
- Remove the SDK v3 shim infrastructure (feature flag routing, command/client maps, v3 error adaptation) and simplify tests/CI accordingly.
- Introduce
provider.getAwsSdkV3Config()plus supporting helpers for SDK v3 client config and credential-provider resolution/caching. - Update plugin documentation to recommend direct AWS SDK v3 client usage and clarify the legacy status of
provider.request()/provider.sdk.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/plugins/aws/provider.js | Removes v3 shim routing; adds getAwsSdkV3Config() and v3 credential provider caching. |
| lib/aws/config.js | Builds AWS SDK v3 client config (region, retries/maxAttempts, proxy/CA/timeout via NodeHttpHandler). |
| lib/aws/credentials.js | New v3 credential-provider resolution logic (profiles/env/stage + default fallback behavior) and cache-key helper. |
| lib/aws/error-utils.js | Removes shim-only v3→v2 error transformation utilities. |
| lib/aws/commands.js | Removes shim command map used to translate v2-style calls to v3 commands. |
| lib/aws/client-factory.js | Removes shim client factory and client map used by the v3 translation layer. |
| package.json | Drops unused AWS SDK v3 client deps and adds @smithy/node-http-handler. |
| test/unit/lib/plugins/aws/provider.test.js | Adds unit coverage for getAwsSdkV3Config() behavior and credential-provider reuse. |
| test/unit/lib/aws/config.test.js | Adds unit coverage for v3 config building (maxAttempts, region fallback, transport options). |
| test/unit/lib/aws/credentials.test.js | Adds unit coverage for default-profile fallback semantics and shared-file detection. |
| test/utils/*.js (api-gateway, websocket, sqs, sns, s3, misc, kinesis, iot, event-bridge, dynamodb, cognito, cloudformation) | Removes dual v2/v3 test-client branches; standardizes on v2-based request helpers. |
| .github/workflows/validate.yml | Removes v2/v3 mode matrix; runs packaging/unit tests once. |
| docs/guides/plugins/*.md | Updates wording and adds guidance for plugin-owned AWS SDK v3 clients + getAwsSdkV3Config() usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 28 out of 28 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The AWS SDK v3 compatibility shim is the wrong long-term architecture.
This PR removes the v2-style SDK v3 request layer and lays the foundation for the new approach:
SLS_AWS_SDK_V3is removed as a runtime mode switch.COMMAND_MAP/CLIENT_MAPcompatibility layer is removed.provider.getAwsSdkV3Config().provider.request()/provider.sdkbehavior for old plugins.Why The Shim Is Removed
The shim tries to keep this AWS SDK v2-era abstraction alive:
AWS SDK v3 does not model AWS calls that way. Its native model is:
Preserving
provider.request(service, method, params)under SDK v3 requires Serverless to maintain a translation layer for every service and method. That creates permanent maintenance cost and an unclear plugin contract.The right fix is not to make the maps extensible. The right fix is to remove the maps.
Scope
In scope:
SLS_AWS_SDK_V3everywhere.COMMAND_MAPandCLIENT_MAP.provider.getAwsSdkV3Config()as the foundation for direct SDK v3 usage.Out of scope:
provider.request()entirely.provider.sdkentirely.New Public Foundation API
The AWS provider now exposes:
The returned config is directly usable with AWS SDK v3 clients:
The returned config includes:
regioncredentialsrequestHandlerwhen proxy, CA, or timeout config requires itmaxAttemptsretryModecustomUserAgentwhen providedPlugin Model
Plugins should own their AWS SDK v3 dependencies.
Example plugin
package.json:{ "dependencies": { "@aws-sdk/client-s3": "^3.0.0" } }Example plugin code:
Plugins should not rely on Serverless' transitive AWS SDK dependencies.
Credentials
getAwsSdkV3Config()exposes credentials as an async AWS SDK v3 credential provider, not as a static snapshot.That is required for:
Credential source order is:
--aws-profileprofilepassed togetAwsSdkV3Config()AWS_${STAGE}_PROFILEAWS_${STAGE}_ACCESS_KEY_IDandAWS_${STAGE}_SECRET_ACCESS_KEYAWS_PROFILEAWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYprovider.profileAWS_DEFAULT_PROFILE || "default"If the selected default profile exists but cannot resolve credentials, the original credential error is rethrown rather than falling through to ambient credentials.
The helper supports:
AWS_SHARED_CREDENTIALS_FILEAWS_CONFIG_FILERegion And Transport
Region resolves from explicit
options.region, otherwiseprovider.getRegion().The config helper carries existing Serverless transport behavior into AWS SDK v3 config for:
AWS_CLIENT_TIMEOUT/aws_client_timeoutThe returned config uses
NodeHttpHandlerwhen custom transport configuration is needed.Core Internals
This change does not migrate core internals yet.
For now:
provider.request()remains available as legacy/internal behaviorprovider.sdkremains AWS SDK v2Future core migration should use direct AWS SDK v3 clients and commands rather than recreating a generic request abstraction.
Legacy Compatibility Package
A future optional package can restore old plugin APIs for users who need abandoned or unported plugins.
Possible package name:
That package can patch:
It should be backed by AWS SDK v2 and clearly documented as legacy. It should not reintroduce v3 command/client maps.