question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sam deploy should accept parameter file just like aws cloudformation *-stack

See original GitHub issue

Description:

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:

  1. 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'}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:44
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

29reactions
jveldboomcommented, Sep 2, 2020

We use a similar pattern to @rojomisin but use a standard environment variable file format.

.sam-params

DBUsername=admin
DBPassword=password123
Subnets=subnet-12345
VpcId=vpc-1234

Then in our Makefile, we cat that file and pass them in as --parameter-overrides

sam deploy --parameter-overrides $(shell cat .sam-params)
22reactions
HFR1994commented, Jan 19, 2021

I’m using jq as an alternative… Having the following structure

// parameters.json

[
  {
    "ParameterKey": "ApplicationName",
    "ParameterValue": "Foo"
  },
  {
    "ParameterKey": "ApplicationKey",
    "ParameterValue": "Bar"
  }
]

I can do

SAM_PARAMETERS=$( cat ${DIR}/parameters.json | jq -r '.[] | "\(.ParameterKey)=\(.ParameterValue)"' )
sam deploy ... --parameter-overrides $SAM_PARAMETERS

The good thing is that file can be shared with Cloudformation templates with:

aws cloudformation deploy ... --parameter-overrides "file://${DIR}/parameters.json"
Read more comments on GitHub >

github_iconTop Results From Across the Web

sam deploy - AWS Serverless Application Model
Objects declared in the Parameters section of the AWS SAM template file appear as additional interactive mode prompts. The AWS SAM CLI prompts...
Read more >
How do I specify template parameters when running AWS ...
You can use the --parameter-overrides in sam deploy just like in aws ... sam deploy --template-file packaged.yaml --stack-name ...
Read more >
A Practical Guide to Surviving AWS SAM - Medium
Once the stack is deployed, parameter values can be retrieved from the CloudFormation console and, for SSM Parameter Store, both value and name...
Read more >
deploy — AWS CLI 2.1.0 Command Reference
--template-file (string) The path where your AWS CloudFormation template is located. --stack-name (string) The name of the AWS CloudFormation stack you're ...
Read more >
Deploying Your Stacks - Stackery Documentation
Install and compile Lambda function dependencies · Create Lambda code package zip files · Upload zip files to s3 · Generate a deployable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found