Cloudformation deploy --parameter-overrides doesnt accept file Workaround

sam deploy parameter-overrides example
cloudformation parameters file
cloudformation parameter-overrides
cloudformation cli parameter overrides
aws value passed to parameter overrides must be of format key value
aws cloudformation deploy region
sam local cloudformation parameters

I am in process of using setting up pipeline using codebuild and use cloudformation package and cloudformation deploy to spin up the stack which spuns lambda function. Now i know that with cloudformation deploy we cant use parameters file with --parameters-overrides and this feature request is still in open state wit AWS . So i am trying to use a workaround using JQ which is decsribed in this link like below.

PARAMETERS_FILE="parameters.json" &&  PARAMS=($(jq -r '.Parameters[] | [.ParameterKey, .ParameterValue] | "\(.[0])=\(.[1])"' ${PARAMETERS_FILE})) - aws cloudformation deploy --template-file /codebuild/output/packaged.yaml --region us-east-2 --stack-name InitialSetup --capabilities CAPABILITY_IAM  --parameter-overrides ${PARAMS[@]}

This workaround works well if tested via cli . I also tried this workaround inside a container as buildspec.yaml file creates a container in background which runs these commands , but codebuild doesnt excute the aws cloudformation deploy step and fails . I get error "aws: error: argument --parameter-overrides: expected at least one argument" . I even tried copying the two steps of workaround in shell script and then executing it but i run into error "[Container] 2020/01/21 09:19:14 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: ./ Reason: exit status 255" Can someone please guide me here .My buildspec.yaml file is as below :

''' version: 0.2

phases: install: runtime-versions: java: corretto8 commands:

- wget -O jq
- chmod +x ./jq
- cp jq /usr/bin
- jq --version 

pre_build: commands: # - echo "[Pre-Build phase]

build: commands:

  - aws cloudformation package --template-file master.yaml --s3-bucket rtestbucket --output-template-file packaged.yaml
  - aws s3 cp ./packaged.yaml s3://rtestbucket/packaged.yaml
  - aws s3 cp s3://rtestbucket/packaged.yaml /codebuild/output

post_build: commands:

- PARAMETERS_FILE="parameters.json" &&  PARAMS=($(jq -r '.Parameters[] | [.ParameterKey, .ParameterValue] | "\(.[0])=\(.[1])"' ${PARAMETERS_FILE}))
- ls 
- aws cloudformation deploy --template-file /codebuild/output/packaged.yaml --region us-east-2 --stack-name InitialSetup --capabilities CAPABILITY_IAM  --parameter-overrides ${PARAMS[@]}

artifacts: type: zip files: - packaged.yaml


CodeBuild buildspec commands are not running in bash shell and I think the syntax:


... is bash specific.

As per the answer here:

Try to wrap your commands in a script file with a shebang specifying the shell you'd like the commands to execute with.

Allow cloudformation deploy to accept a paramater file � Issue #2828 , In case anyone is looking for a workaround, you can try using jq, like so: aws cloudformation deploy --parameter-overrides $(jq -r '. other issues - I am surprised after 3 years it still does not have parity with those old methods. accept via --parameters file://params.json , and with some extra work probably� +1 for this. I understand wanting to keep "aws cloudformation deploy" simple, but this command already has individual command line flags for capabilities, tags, and parameters (like all other aws cloudformation commands), but you've made them function differently (only accepting list of string=string on the command line, rather than a JSON structure in a file).

The expression ${PARAMS[@]} is not returning any value, which causes the error aws: error: argument --parameter-overrides: expected at least one argument. Review the code and resolve, or remove that parameter.

Is there no way to specify a parameters file? � Issue #111 � awslabs , aws cloudformation deploy --template-file packaged-template.yaml --parameter- overrides $(cat --capabilities� aws cloudformation deploy --template-file packaged-template.yaml --parameter-overrides $(cat --capabilities CAPABILITY_IAM --stack-name test But definitely it should be more straightforward and deploy command should allow you to just pass a file.

I was able to resolve this issue with executing the all the required steps in shell script and providing access to script.

deploy — AWS CLI 1.18.121 Command Reference, --template-file (string) The path where your AWS CloudFormation template is located --parameter-overrides (list) A list of parameter structures that specify input� 0 Cloudformation deploy --parameter-overrides doesnt accept file Workaround Jan 22 0 Application deployed only in Private Subnet Nov 15 '19 0 Using SAM deploy or Cloudformation deploy in CodeBuild Jan 10

Aws cloudformation deploy parameter overrides file, aws cloudformation deploy --region us-east-2 --template-file packaged yaml \ -- stack-name CoolStack \ --parameter-overrides CoolNumber=1 aws cloudformation But that doesn't make it less complex and less cryptic at times Until we fix this bug, you can override the parameter explicitly when you add a new� Description: I want to hand over parameters to the deployment of my cloudformation template using cloudformation deploy --parameter-overrides. Some parameters might contain spaces which are parsed in a wrong way.

Aws cloudformation parameter file, You can receive this error when you use an AWS-specific parameter: To pass Jul 31, 2018 � aws cloudformation deploy --template-file output. cloudformation template using cloudformation deploy --parameter-overrides. There are probably some parameters that could get moved to EC2 scripts, but that doesn't help at� Workaround: provide a Default value for all parameters The --parameter-override arguments are not space separated "name=value" pairs as documented, nor are they comma separated. I have not been able to pass more than one parameter.

Aws cloudformation parameter file, --template-body file://. yml # パラメータは --parameters の後に This resource accepts a single parameter, the CloudFormation Stack name which uniquely you use an AWS-specific parameter: To pass a value that doesn't exist in the AWS my cloudformation template using cloudformation deploy --parameter- overrides. Parameter overrides let you specify template parameter values that override values in a template configuration file. AWS CloudFormation provides functions to help you to specify dynamic values (values that are unknown until the pipeline runs).

  • What do you expect to see from the ${PARAMS[@]} expression.
  • Well the output would be getting the parameters in single line from parameters.json so that these can be passed to --parameter-overrides. Well this workaround is for passing a file instead of indivual key value pairs for parameters.
  • i want to pass the parameter file while using cloudformation deploy and using ${PARAMS[@]} and jq is one of the workaround . This workaround works on local and also tried inside a container but doesnt work on code build hence the issue . workaround is as below : PARAMETERS_FILE="parameters.json" && PARAMS=($(jq -r '.Parameters[] | [.ParameterKey, .ParameterValue] | "(.[0])=(.[1])"' ${PARAMETERS_FILE})) - aws cloudformation deploy --template-file /codebuild/output/packaged.yaml --region us-east-2 --stack-name InitialSetup --capabilities CAPABILITY_IAM --parameter-overrides ${PARAMS[@]}