Skip to content

Migrate to AWS SDK V3 - Part 1#65

Merged
mnapoli merged 27 commits into
mainfrom
aws-sdk-v3
Aug 4, 2025
Merged

Migrate to AWS SDK V3 - Part 1#65
mnapoli merged 27 commits into
mainfrom
aws-sdk-v3

Conversation

@GrahamCampbell

@GrahamCampbell GrahamCampbell commented Jun 8, 2025

Copy link
Copy Markdown
Contributor

This PR adds AWS SDK v3 support for everything. Opt in to v3 with SLS_AWS_SDK_V3=1. I am running the CI on both versions in the Node 22 job... however mostly things are mocked, so this is not testing much. A notable difference is that the v2 SDK has memoization that we expose with useCache. We are not doing that for v3. Do we want that?

In a follow-up PR we could flip the default (Part 2), and in another follow-up, remove v2 support (Part 3).


Smashing through this with Claude Code. 🤖

Comment thread lib/configuration/variables/sources/instance-dependent/get-aws.js Outdated
@GrahamCampbell GrahamCampbell changed the title Migrate to AWS SDK V3 Migrate to AWS SDK V3 - Part 1 Jun 8, 2025
@GrahamCampbell GrahamCampbell marked this pull request as ready for review June 8, 2025 23:25
@GrahamCampbell GrahamCampbell requested a review from mnapoli June 8, 2025 23:26
@GrahamCampbell GrahamCampbell marked this pull request as draft June 8, 2025 23:57
@GrahamCampbell GrahamCampbell marked this pull request as ready for review June 9, 2025 00:44
Comment thread lib/configuration/variables/sources/instance-dependent/get-aws.js Outdated
CreateRoleCommand,
AttachRolePolicyCommand,
} = require('@aws-sdk/client-iam');
const AWSClientFactory = require('../../../../../aws/client-factory');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't these files the custom resource handlers?

If yes, they shouldn't be impacted by the changes in the CLI. And they wouldn't be able to require files from the CLI package (because they would run in Lambda).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this was a fix to make sure they are re-using the same client.

@mnapoli mnapoli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through the changes and did some basic tests, things seem to work with the v3 SDK. I also cleaned up the diff.

The last thing we need to figure out for me are the custom resources: I don't see why they are impacted here. I'd revert them entirely but I'm not sure if I'm missing something, so I'll wait for your take on this.

@GrahamCampbell

Copy link
Copy Markdown
Contributor Author

The changes to those are not strictly necessary, but they should improve performance by re-using the TPC connections.

@mnapoli

mnapoli commented Jul 31, 2025

Copy link
Copy Markdown
Contributor

@GrahamCampbell but wait I don't understand at all.

Custom resource handlers are deployed in AWS lambda in users accounts. They don't have the whole codebase of serverless framework, nor its dependencies. I don't see how it's possible that a custom resource handler requires from the rest of the codebase, that makes no sense to me. https://github.com/oss-serverless/serverless/blob/1f3039673266a4bd88188ef4c8aa728c8cfeb6c8/lib/plugins/aws/custom-resources/resources/README.md#L4-L3

@GrahamCampbell

Copy link
Copy Markdown
Contributor Author

OK, sure. We can revert those changes.

@mnapoli mnapoli merged commit 139880d into main Aug 4, 2025
3 checks passed
@mnapoli mnapoli deleted the aws-sdk-v3 branch August 4, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants