feat: support osls v4 (migrate provider.request to AWS SDK v3)#789
feat: support osls v4 (migrate provider.request to AWS SDK v3)#789jbsilva wants to merge 1 commit into
Conversation
osls v4 removed the bundled AWS SDK v2 surface, so provider.request() now throws AWS_SDK_V2_SURFACE_REMOVED and any deploy of a service using this plugin fails during getEndpointInfo (CloudFormation:describeStacks). Add an awsRequest() helper that builds the matching AWS SDK v3 client via provider.getAwsSdkV3Config() when available (osls v4) and otherwise falls back to the legacy provider.request() (serverless v3). Route all five call sites (deploy endpointInfo and invoke) through it. The request params and response fields already match between the v2 and v3 APIs used here. Also declare osls (>=4) as an optional peer dependency. Adds unit tests for awsRequest covering the v3 path, the legacy fallback, and unsupported calls.
bartelemi
left a comment
There was a problem hiding this comment.
This is really neat 💪🏻
Would really like to see this included in the next release of the plugin. This is the last piece that is stopping us from migration to OSLS v4.
Thanks! I actually published my fork to npm yesterday: https://www.npmjs.com/package/@jbsilva/serverless-step-functions But having this upstream would be great. |
|
Thanks for the PR, looks good! @VirtueMe what do you think? |
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #789 +/- ##
===========================================
+ Coverage 0 99.43% +99.43%
===========================================
Files 0 65 +65
Lines 0 6033 +6033
===========================================
+ Hits 0 5999 +5999
- Misses 0 34 +34 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Problem
Under osls v4, the bundled AWS SDK v2 surface was removed, so
provider.request()now throws:Because
getEndpointInfo()callsprovider.request('CloudFormation', 'describeStacks', ...)on every deploy, any service that uses this plugin fails to deploy on osls v4. Theinvokecommand hits the same wall via four moreprovider.request()calls.Change
awsRequest()helper (lib/awsRequest.js). When the provider exposesgetAwsSdkV3Config()(osls v4), it builds the matching AWS SDK v3 client (@aws-sdk/client-cloudformation,@aws-sdk/client-sfn) and sends the command. Otherwise it falls back to the legacyprovider.request()(serverless v3), so existing behavior is unchanged.deploy/events/apiGateway/endpointInfo.jsand the four ininvoke/invoke.js.describeStacks→Stacks[].Outputs,startExecution→executionArn,describeExecution→status,getExecutionHistory→events), so call sites stay otherwise untouched.osls(>=4) as an optional peer dependency.Backward compatibility
On serverless v3 (where
getAwsSdkV3Configis absent) the helper delegates toprovider.request()with the exact same arguments, so there is no behavior change. The existing unit tests, which stubprovider.request, continue to pass unchanged.Tests
npm test: 616 passing (613 existing + 3 new).lib/awsRequest.test.jscovers the SDK v3 path (via a stubbedCloudFormationClient.prototype.send), the legacyprovider.requestfallback, and rejection on an unsupported service/method.eslintclean on all changed files.Verified end to end by deploying a real service (API Gateway + Step Functions) on osls v4.
Note on
package-lock.jsonI intentionally did not regenerate
package-lock.json. The current tree has a pre-existing dev-dependency peer conflict (eslint@^10vseslint-config-airbnb-extended@3.0.1) that forces--legacy-peer-depsand rewrites the entire lock, which would bury this change in noise. Please regenerate the lockfile in your environment to pick up the two new runtime deps (@aws-sdk/client-cloudformation,@aws-sdk/client-sfn).