Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add architecture validations for SAM build LambdaLayer #6322

Merged
merged 19 commits into from
Nov 29, 2023

Conversation

bentvelj
Copy link
Contributor

  • Add a validation check for LambdaLayer BuildArchitecture to ensure that it is a valid architecture and one of the CompatibleArchitectures listed. If the BuildArchitecture is invalid, only a warning is displayed to inform the customer. Hard failing is not done for Makefile BuildMethod to preserve customer freedom in building with their own Makefile.

  • Adds architecture validation for when --use-container is specified for building a LambdaLayer. This now gives the customer a much clearer error message regarding the architecture instead of a "failed to pull image" error. (@mndeveci's changes)

  • Adds integration test to verify that a clear error message is displayed in the case of a customer attempting to build a function with an invalid architecture.

Which issue(s) does this change fix?

#6110

Why is this change necessary?

  • Customers may be confused why LambdaLayers with invalid BuildArchitectures still build just fine. A warning message will help customers catch possible errors in their template.

  • Regarding the --use-container option for building a layer, reporting an invalid architecture error addresses the actual root of the problem instead of showing a consequence of having an invalid architecture ("failed to pull image" error). This makes it easier for customers to resolve.

How does it address the issue?

  • Add warning message if the LambdaLayer being built has a BuildMethod of Makefile. Architecture validation for other BuildMethods are already done in LambdaBuilders, but nothing is done for Makefile.

What side effects does this change have?

N/A

Mandatory Checklist

PRs will only be reviewed after checklist is complete

  • Add input/output type hints to new functions/methods
  • Write design document if needed (Do I need to write a design document?)
  • Write/update unit tests
  • Write/update integration tests
  • Write/update functional tests if needed
  • make pr passes
  • make update-reproducible-reqs if dependencies were changed
  • Write documentation

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@bentvelj bentvelj requested a review from a team as a code owner November 23, 2023 00:28
@github-actions github-actions bot added area/local/start-api sam local start-api command area/build sam build command area/local/invoke sam local invoke command area/local/start-invoke pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Nov 23, 2023
Copy link
Contributor

@mildaniel mildaniel left a comment

Choose a reason for hiding this comment

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

Thanks Jared, LGTM overall. Left a few minor comments.

Let's also write some unit tests for the changes in lib/build to ensure we don't lose coverage there.

samcli/local/docker/lambda_build_container.py Outdated Show resolved Hide resolved
tests/integration/buildcmd/test_build_cmd.py Outdated Show resolved Hide resolved
tests/integration/buildcmd/test_build_cmd.py Outdated Show resolved Hide resolved
samcli/lib/build/build_strategy.py Outdated Show resolved Hide resolved
samcli/lib/build/utils.py Outdated Show resolved Hide resolved
Copy link
Contributor

@sidhujus sidhujus left a comment

Choose a reason for hiding this comment

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

LGTM

@bentvelj bentvelj added this pull request to the merge queue Nov 29, 2023
Merged via the queue into develop with commit 0ae8569 Nov 29, 2023
55 checks passed
@bentvelj bentvelj deleted the bentvels_fix_6110 branch November 29, 2023 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build sam build command area/local/invoke sam local invoke command area/local/start-api sam local start-api command area/local/start-invoke pr/internal stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants