You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sam deploy should accept parameter file just like aws cloudformation *-stack #2054
I would like to store configuration is version control and make deployment steps immutable. Instead of changing parameter overrides on the command line I would like to provide template parameters from a file.
There is an idiom for this in aws cloudformation create-stack --parameters file://.
Steps to reproduce the issue:
sam deploy --parameter-overrides file://params.json
Observed result:
Error: Invalid value for '--parameter-overrides': file://params.json is not in valid format. It must look something like 'ParameterKey=KeyPairName,ParameterValue=MyKey ParameterKey=InstanceType,ParameterValue=t1.micro' or 'KeyPairName=MyKey InstanceType=t1.micro'
Expected result:
Deploying with following values
===============================
Stack name : ...
Region : ...
Confirm changeset : ...
Deployment s3 bucket : ...
Capabilities : ...
Parameter overrides : {'MyParamOverride': 'MyParamValue'}
Reacted by Sriram Madapusi Vasudevan, Brendan McCollam and Chris
Reacted by K, Andre Silva, Ygor Almeida, Anthony Poschen, Aaron Roydhouse, Aaron Houlihan, Rob Taylor, apriceaws, Davey Bartle, Leonard 'Lenny' Daume and 15 more
I am trying to set a parameter that is specified in the template. There is no hint in the documentation that this should be possible but following your suggestion it tried the following:
Parameter defined in the template:
Parameters:
AllowedSrcIp:
Type: "String"
Description: "IP address of the client used for testing. If in doubt, deploy the code and the output will guide you"
Default: "192.168.0.1"
Updated samconfig.toml with the parameters directly:
sam deploy
Usage: sam deploy [OPTIONS]
Try 'sam deploy --help' for help.
Error: Missing option '--stack-name', 'sam deploy --guided' can be used to provide and save needed parameters for future deploys.
both of which do work but are really hard to maintain if you have more than a couple parameters or if your parameters need complex quoting. In fact it turns out that if you were to enter the data interactively as a result of using sam deploy --guided it will create something like this which highlights the issue:
Reacted by Adrian Mowat, ykwek, Dan Rogers, miconer, Mike Dalrymple, Matt Beckett, Adam Perry, Anthony Poschen, Aaron Roydhouse, Aaron Houlihan and 20 more
Reacted by Karl Skidmore, Chris, Andre Silva, Anthony Poschen, Aaron Roydhouse, Vivien S, koalabooxapi, Dinesh-Vajja, Kyle Florence, Fabrício Girardi Andreis and 8 more
Reacted by Ygor Almeida, Anthony Poschen, Aaron Roydhouse, Dinesh-Vajja, Fabrício Girardi Andreis, Avi Mehenwal, pistolilla, Bhavin Tandel, JTH and Havilash Sivaratnam
samconfig.toml is yet another different and, and as otherspointedout, worse way to maintain AWS parameters, using yet another file format on top of YAML and JSON! Why are we trying so hard to make life more complicated 😄
cloudformation deploy has added support for --parameter-overrides file://my-params.json in aws/aws-cli#5443, including the also different and incompatible CodePipeline parameters format.
if sam is a wrapper for cloudformation deploy which now, or soon, supports --parameter-overrides files://my-params.json, can sam pick up on that and resolve this issue?
Reacted by Chris, Daivat Bhatt, Miklós Lőrinczi, Mauro, Aaron Houlihan, Diego H. Gurpegui, Davey Bartle, J. Gregory Wright, Connor Vanderhook, Ronaldo Umana and 17 more
I need to use a SAM parameter to upload a private RSA key in PEM format to AWS SecretsManager.
I've been trying all kinds of things on the CLI (including everything above) to get this to work. I ended up giving up and writing this workaround in my python code:
importbase64importboto3# AWS CLI can't (easily) take params with newlines or spaces. Thus, we base64 encode our RSA PEM# to make it single line before we upload it to Secrets Manager. See docs/design-notes.mddefget_lighthouse_rsa_key(awsSecretArn): # pragma: no coversmClient=boto3.client("secretsmanager")
base64EncodedPem=smClient.get_secret_value(SecretId=awsSecretArn)["SecretString"]
resultBytes=base64.b64decode(base64EncodedPem)
returnresultBytes.decode()
I would be thankful if the SAM CLI maintainers incorporate @whereisaaron 's suggestion above on April 5th, 2021.
Note: Another part of the problem plaguing with (most) PEM files is the fact that CloudFormation parameters can be 4096 bytes, max. To support PEM files (at least those that are more than 4096 bytes) CloudFormation would need to provide an attribute to each parameter to override the 4096 byte max. Perhaps an attribute like MaxBytes: AN_INTEGER. But that's a different topic than this thread.
I would love to see SAM having a built-in easier way to do this. It becomes a maintenance hell unless the developers implement workarounds like @HFR1994 and @jveldboom suggested.
How should configure it in a pipeline without load credentials to git if I need the value of the Parameters in build phase, because the lambda download an private pypi package which require authentication?
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Activity
jfuss commentedon Jun 18, 2020
Why not use the samconfig.toml file? https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html
rudpot commentedon Jun 18, 2020
I am trying to set a parameter that is specified in the template. There is no hint in the documentation that this should be possible but following your suggestion it tried the following:
Parameter defined in the template:
Updated
samconfig.tomlwith the parameters directly:The deploy works but doesn't honor the new parameter. Looking at the structure of the config I also tried this line:
Which breaks the deployment entirely:
And this:
And this:
both of which do work but are really hard to maintain if you have more than a couple parameters or if your parameters need complex quoting. In fact it turns out that if you were to enter the data interactively as a result of using
sam deploy --guidedit will create something like this which highlights the issue:what-name commentedon Jul 25, 2020
As @rudpot mentioned, the following
parameter_overridesvalue is rather tedious to maintain with more than a couple entries:+1 for a simpler approach.
rojomisin commentedon Aug 25, 2020
work around until a file can be used is to wrap w/ shell or make
load up a config file with k/v pairs and use
make's includemake sam-deploy CONFIG=devjveldboom commentedon Sep 2, 2020
We use a similar pattern to @rojomisin but use a standard environment variable file format.
.sam-params
Then in our Makefile, we
catthat file and pass them in as--parameter-overridesjaridspokes commentedon Sep 28, 2020
I've used the above workaround for now, but it would be great to get some consistency with cloudformation in this regard.
benkehoe commentedon Oct 18, 2020
#2253 proposes parameter overrides should get their own section in
samconfig.toml(and should be individually overridden by--parameter-overrides)HFR1994 commentedon Jan 19, 2021
I'm using jq as an alternative.... Having the following structure
// parameters.json
I can do
The good thing is that file can be shared with Cloudformation templates with:
whereisaaron commentedon Apr 5, 2021
samconfig.tomlis yet another different and, and as others pointed out, worse way to maintain AWS parameters, using yet another file format on top of YAML and JSON! Why are we trying so hard to make life more complicated 😄cloudformation deployhas added support for--parameter-overrides file://my-params.jsonin aws/aws-cli#5443, including the also different and incompatible CodePipeline parameters format.if
samis a wrapper forcloudformation deploywhich now, or soon, supports--parameter-overrides files://my-params.json, cansampick up on that and resolve this issue?mountHouli commentedon Jun 4, 2021
I need to use a SAM parameter to upload a private RSA key in PEM format to AWS SecretsManager.
I've been trying all kinds of things on the CLI (including everything above) to get this to work. I ended up giving up and writing this workaround in my
pythoncode:I would be thankful if the SAM CLI maintainers incorporate @whereisaaron 's suggestion above on April 5th, 2021.
Note: Another part of the problem plaguing with (most) PEM files is the fact that CloudFormation parameters can be 4096 bytes, max. To support PEM files (at least those that are more than 4096 bytes) CloudFormation would need to provide an attribute to each parameter to override the 4096 byte max. Perhaps an attribute like
MaxBytes: AN_INTEGER. But that's a different topic than this thread.8 remaining items
yigiterinc commentedon Jul 24, 2022
I would love to see SAM having a built-in easier way to do this. It becomes a maintenance hell unless the developers implement workarounds like @HFR1994 and @jveldboom suggested.
JaimySmets commentedon Nov 6, 2022
Perhaps an easier workaround than custom wrapper scripts, is to use TOML's multiline support in the
samconfig.tomlfile.Which it seems to parse just fine during
sam deploy:Although I agree putting it in a separate file would look cleaner, at least this way it remains the default
sam deploy.benkehoe commentedon Nov 6, 2022
@JaimySmets as mentioned in #2253 (comment) it also works with a list
either way it doesn't solve for the parameters needing to be managed separately from the
samconfig.tomlfilejhonatanacelas commentedon Feb 14, 2023
How should configure it in a pipeline without load credentials to git if I need the value of the Parameters in build phase, because the lambda download an private pypi package which require authentication?
liamfit commentedon Mar 3, 2023
This worked great for me until I started trying to use parameters whose values were lists:
modnar1226 commentedon Feb 26, 2025
If any one like me really disliked the TOML format, you can use yaml format and use the following for multi line support:
Add file:// parameter support to sam deploy
vicheey commentedon Dec 17, 2025
merging pr: #7876
github-actions commentedon Dec 17, 2025
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.