Skip to content

fix(aws/custom-resources): propagate provider.architecture to custom resource Lambda#159

Merged
mnapoli merged 1 commit intooss-serverless:mainfrom
babyhuey:fix/custom-resources-architecture
Apr 22, 2026
Merged

fix(aws/custom-resources): propagate provider.architecture to custom resource Lambda#159
mnapoli merged 1 commit intooss-serverless:mainfrom
babyhuey:fix/custom-resources-architecture

Conversation

@babyhuey
Copy link
Copy Markdown

Summary

Fixes #116. The internal custom resource Lambda (used for S3 notifications, Cognito user pools, Event Bridge, and the API Gateway CloudWatch role) was always deployed as x86_64 because Architectures was never set on the generated CloudFormation resource, regardless of provider.architecture in serverless.yml.

Changes

  • lib/plugins/aws/custom-resources/index.js: when provider.architecture is configured, set Properties.Architectures on the compiled custom resource AWS::Lambda::Function. Mirrors the pattern already used for user-defined functions in lib/plugins/aws/package/compile/functions.js.
  • No new config surface — this extends where the existing, schema-validated provider.architecture value is applied.

Tests

Two new cases in test/unit/lib/plugins/aws/custom-resources/index.test.js:

  • Architectures is set to ['arm64'] when provider.architecture is 'arm64'.
  • Architectures is omitted when provider.architecture is unset (preserves current x86_64 default behavior).

All 14 tests in the custom-resources suite pass. Full unit suite (SDK v2 and v3), packaging tests (v2 and v3), isolated tests, prettier, and eslint all pass locally.

…resource Lambda

The internal custom resource Lambda (used for S3 notifications, Cognito
user pools, Event Bridge, and the API Gateway CloudWatch role) was
always deployed as x86_64 because `Architectures` was never set on the
generated CloudFormation resource, regardless of `provider.architecture`
in serverless.yml.

Mirror the pattern already used for user-defined functions in
lib/plugins/aws/package/compile/functions.js: when `provider.architecture`
is configured, set `Properties.Architectures` on the custom resource
function.

Closes oss-serverless#116
@mnapoli
Copy link
Copy Markdown
Contributor

mnapoli commented Apr 22, 2026

Thanks, a genuine question: what difference does it make in the end? It's not like cost optimization is a factor here since these have a very low number of invocations.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Propagates the existing, schema-validated provider.architecture setting to the internally generated AWS custom resource Lambda functions so they can be deployed as arm64 (or explicitly x86_64) instead of always defaulting to x86_64.

Changes:

  • Set Properties.Architectures on the generated AWS::Lambda::Function for custom resources when provider.architecture is configured.
  • Add unit tests to verify Architectures: ['arm64'] is emitted when configured and omitted when not configured.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/plugins/aws/custom-resources/index.js Applies provider.architecture to compiled custom resource Lambda function Properties.Architectures.
test/unit/lib/plugins/aws/custom-resources/index.test.js Adds coverage for setting/omitting Architectures based on provider.architecture.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@babyhuey
Copy link
Copy Markdown
Author

Thanks, a genuine question: what difference does it make in the end? It's not like cost optimization is a factor here since these have a very low number of invocations.

Honestly, I wanted to contribute, and I saw the open Issue so I thought it would be a good place for me to dip my toes in. If you don't think this is worth it, feel free to close it!

@mnapoli
Copy link
Copy Markdown
Contributor

mnapoli commented Apr 22, 2026

Go it! Let's merge, I guess this doesn't hurt and some people may appreciate if they have some policies to always use ARM for example.

@mnapoli mnapoli merged commit 5912180 into oss-serverless:main Apr 22, 2026
7 checks passed
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.

Custom Resources to use arm64

3 participants