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

SAM build not honouring --profile or --region #5390

Closed
cc-simon opened this issue Jun 21, 2023 · 5 comments
Closed

SAM build not honouring --profile or --region #5390

cc-simon opened this issue Jun 21, 2023 · 5 comments
Labels
area/build sam build command stage/waiting-for-release Fix has been merged to develop and is waiting for a release

Comments

@cc-simon
Copy link

cc-simon commented Jun 21, 2023

Description:

SAM build will not use a profile or region passed in on the command line, the SAM build command requires these parameters to be setup as env variables or as defaults in the .aws/config file

Steps to reproduce:

Install the latest version of SAM

create a template containing a Type: AWS::Serverless::Application resource

remove any environment variables or defaults in the .aws/config file

run sam build --profile [profilename]

OR

run sam build --region [regionname]

Observed result:

Build fails

Expected result:

Build should succeed

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

{
"version": "1.84.0",
"system": {
"python": "3.8.17",
"os": "macOS-12.3-arm64-arm-64bit"
},
"additional_dependencies": {
"docker_engine": "Not available",
"aws_cdk": "Not available",
"terraform": "Not available"
},
"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"
]
}

  1. OS: Mac and Windows
  2. sam --version: 1.84.0
  3. AWS region: n/a

I believe the bug is in this line of code-
https://github.com/aws/serverless-application-model/blob/23a882bc405cd598c8ae330a470116864485ad8f/samtranslator/region_configuration.py#L52

This bug shows that the test environment is either using seeded data or the test suites are incomplete

@cc-simon cc-simon added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Jun 21, 2023
@sriram-mv
Copy link
Contributor

Thanks for your report!

sam build calls through to aws-sam-translator to get the template to operate and in the process runs a series of plugins. It looks like in this particular case, there is a hook method that is run before the sam template is processed from the ServerlessAppPlugin which validates if one has the access to the resources present in the AWS::Serverless::Application section, for which it checks if Serverless Application Repository is present in a particular region.

Agreed on build not throwing a stack-trace.

@sriram-mv sriram-mv added stage/needs-investigation Requires a deeper investigation 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 Jun 21, 2023
@sriram-mv
Copy link
Contributor

PR has been merged to aws-sam-translator and will be released with the next release of aws-sam-translator to pypi, followed by a aws-sam-cli release.

@sriram-mv sriram-mv added stage/waiting-for-release Fix has been merged to develop and is waiting for a release and removed stage/needs-investigation Requires a deeper investigation labels Jun 27, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2023

Patch is released in v1.90.0. Closing

@github-actions github-actions bot closed this as completed Jul 6, 2023
@mndeveci
Copy link
Contributor

mndeveci commented Jul 6, 2023

Re-opening this issue as new version of SAMT have not been released yet

@mndeveci mndeveci reopened this Jul 6, 2023
@github-actions
Copy link
Contributor

Patch is released in v1.91.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
Projects
None yet
Development

No branches or pull requests

3 participants