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

Bug: sam build is warning about missing BuildArchitecture in a layer when I don't have one. #6444

Closed
mew1033 opened this issue Dec 13, 2023 · 10 comments
Labels
area/build sam build command stage/waiting-for-release Fix has been merged to develop and is waiting for a release type/bug type/ux

Comments

@mew1033
Copy link

mew1033 commented Dec 13, 2023

Description:

I have a template that defines a AWS::Serverless::Function resource. It has a Layers section:

      Layers:
        - !Sub arn:${AWS::Partition}:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:45

When I sam build the template, it gives me the following warning 3 times:

WARNING: No BuildArchitecture specifed in Layer None Metadata. Defaulting to x86_64.

Removing the layers section makes the warning go away.

I don't think the warning causes any issues, but it doesn't seem like it should be there.

Steps to reproduce:

Observed result:

2023-12-13 15:26:27,691 | WARNING: No BuildArchitecture specifed in Layer None Metadata. Defaulting to x86_64.

Expected result:

No warning

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Ubuntu 22.04 (in WSL)
  2. sam --version: 1.105.0
  3. AWS region:
{
  "version": "1.105.0",
  "system": {
    "python": "3.11.3",
    "os": "Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with-glibc2.35"
  },
  "additional_dependencies": {
    "docker_engine": "24.0.7",
    "aws_cdk": "Not available",
    "terraform": "1.6.5"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}
@mew1033 mew1033 added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Dec 13, 2023
@hnnasit
Copy link
Contributor

hnnasit commented Dec 13, 2023

Hi @mew1033, thanks for reporting the issue, marking this as a UX bug.

@hnnasit hnnasit added type/ux type/bug area/build sam build command and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Dec 13, 2023
@jojo786
Copy link

jojo786 commented Dec 18, 2023

Also getting this warning when using LambdaAdapterLayer

@jim-meyer
Copy link

Also note that the warning text is misleading. It refers to BuildArchitecture but looking at https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html#sam-function-architectures and https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-layerversion.html I see no mention of a field named BuildArchitecture. I do see a field named Architectures for AWS::Serverless::Function and CompatibleArchitectures for AWS::Serverless::LayerVersion, but no BuildArchitecture.
I tried explicitly defining Architectures and CompatibleArchitectures in my SAM template file but the warning still occurs.

@efremsternbach
Copy link

I am observing this same problem with sam versions 1.104 and 1.105. Version 1.103 works just fine

@major-mayer
Copy link

The BuildArchitecture needs to be specified in the Metadata section: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/building-layers.html
However, this warning is not really necessary when the user just wants to copy the existing content from the ContentUri section to the build folder.

@efremsternbach
Copy link

The confusion for myself and others is likely that the main documentation for LayerVersion does not explicitly show Metadata as a field for the AWS::Serverless::LayerVersion type.

https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-layerversion.html

In addition this didn't used to be necessary. For sam 1.103 and earlier no errors were indicated. Everything worked previously by just specifying CompatibleArchitectures. The new requirements are confusing since I'm just using python anyway. Seems like I have to specify the platform twice because of the new rules.

@efremsternbach
Copy link

I need to follow up on my comment.

In my layer I am using pure python code so it seems kind of ridiculous to specify a BuildArchitecture. I specify that my layer is compatible with x86_64 and arm64 since I don't want to have separate layers for each architecture. I try to use arm64 where possible but occasionally there are modules that don't seem to be compatible so I need to run my Lambda on x86_64.

What am I supposed to specify for BuildArchitecture? Unlike CompatibleArchitectures there is no way to specify more than one architecture. I don't bundle the modules in the layer in order to maintain an architecture neutral layer (my requirements.txt file is empty).

This seems poorly thought out to me. It also breaks a lot of code that had been working perfectly up to sam 1.103.

For code that doesn't actually have an architecture this is a big problem. Is there someone to contact at AWS to make these points?

@efremsternbach
Copy link

Trying to work through this but now getting

WARNING: No BuildArchitecture specifed in Layer None Metadata. Defaulting to x86_64

which makes no damn sense. There are no unnamed layers in my code.

I thought it might be that I need to specify BuildArchitecture for the Lambdas in my application but I'm getting this warning 6 times when I only have 4 Lambas in that application. I have no clue what this is complaining about.

Sorry if it offends anyone but this is a disaster. Much pain for zero gain. It is truly worrisome.

@shanecandoit
Copy link

This also affects sam --version: 1.106.0

@bentvelj bentvelj added stage/waiting-for-release Fix has been merged to develop and is waiting for a release type/bug and removed type/bug labels Jan 9, 2024
Copy link
Contributor

Patch is released in v1.107.0. Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build sam build command stage/waiting-for-release Fix has been merged to develop and is waiting for a release type/bug type/ux
Projects
None yet
Development

No branches or pull requests

8 participants