-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 --parameter-overrides
fails to override
#1490
Comments
@diablodale I think you have a misunderstanding of the output of The template build produces will not write a mutated version of the passed in template, this is by design. |
Correction: We do mutate but this is to update the CodeUri part of the template to point at the new built code. |
Quite possible as I'm guessing in areas of ambiguity (to me). What is a specific example (specific key and specific value) of using I saw that some part of Perhaps this is all ambiguity in the docs and not a feature bug. If more clarify can be brought to |
One example would be passing in Layer ARNs through Parameters. If you It does override the value of the Parameter, but that does not mean we update the "Default" value or replace that parameter in the outputted template. The concept comes from CloudFormation, where you can set defaults in the template but override them at execution time. CloudFormation does not alter the template either just the 'in memory' version of the resource graph. |
Ooo, that's super-subtle. What just now clicked for me is 'in memory'. Production CloudFormation mutates things 'on-disk'. Yes, it can receive a param that overrides the CloudFormation template default, but when it writes 'on-disk' to an EC2 instance, CloudWatch rule, or any other created resource that references that overridden param...that's on-disk. It's not just in-memory. And those on-disk mutations persist and may further propagate if the created resources do creation of their own. Since the
That brings the behavior of
|
I don't think mutating and writing it to disk is the right thing to do for build. Doing what you are suggesting, isn't ideal for how many customers setup pipelines. The recommended/best practice is to build -> package to produce a single template with all artifacts, then deploy that to regions/accounts. In these cases, you do not want build to set defaults because your template becomes very narrow. Yes, you could then do many builds but the CloudFormation way to do this is through Parameters and then overriding them at deploy time. The path forward here would be to only use |
I verified What remains, for me, is the case for when metadata (like the git commit hash) is desired on the That written, there is a technical workaround that can achieve most. I can pass my git hash with Unless you have comments on the above, I consider |
@diablodale You have a really good point. I think #1503 is going to enable this capability. Please take a look at the design and provide comments. You have an interesting perspective and I think we can all benefit from it. Closing this Issue because |
I'm light on time this week. If not this, then I already booked some time on Monday 18 Nov to look at the linked doc. |
feedback in #1546 |
any workaround for #1948 |
This feature is extremely confusing, my expectations were that |
Note to those who do use CodePipeline's built in CloudFormation deploy option who were tripped up by this: Look in the advanced options in the Deploy stage. There is a JSON input field for parameter overrides that does what you want it to (if you don't resort to scripting the deploy). |
What's the proper way to specify the CPU architecture during Parameters:
CPUArchitecture:
Type: String
Default: arm64
AllowedValues:
- arm64
- x86_64
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python3.9
AutoPublishAlias: live
Architectures:
- Ref: CPUArchitecture |
I'm having the same problem as @Manouchehri with specifying the architecture to be built with |
Description
sam build --parameter-overrides
fails to override SAM template yamlParameters
Setup
requirements.txt
app.py
parampoof.yaml
parampoof.yaml
Steps to reproduce
sam build \ --template ./parampoof.yaml \ --manifest requirements.txt \ --parameter-overrides "ParameterKey=GitTag,ParameterValue=aabbccdd" grep aabbccdd .aws-sam/build/template.yaml
Observed result
First...
Then...
Nothing.
grep
finds no value ofaabbccdd
in the fileExpected result
grep
should find the valueaabbccdd
in the file. Likely inParameters:
section by overriding/replacing the default valuedefaultgittag
. This is needed because the next stepssam package
andsam deploy
in the workflow depend on this.aws-sam/build/template.yaml
transformed output ofsam build
.Debug output of
sam build
Workaround
Don't use
sam build --parameter-overrides
. Instead usesed
to search/replace the base template.yaml for a known value to replace/override.Related
#572
The text was updated successfully, but these errors were encountered: