Emulate console CloudFormation stack update on CLI

Based on my reading of the docs for the CFN CLI, it works quite differently from the default behavior of the CFN console. Mainly, there are a number of inputs that you must provide every time on the CLI, where the console uses the previous values. Stack parameters, for example, but there are quite a few others

Does anyone have a good example of using the CFN CLI that works the same way as the console? The primary use would be updating the stack template (ie, upload a new template, and then click next-next-next-next-next…).

It seems like to do that, you have to make a request to the API, get the stack details, parse out a bunch of stuff that isn’t necessarily easy to parse in bash, and then feed it all, unchanged, back to the update command.

Or am I mistake about that?


Related discussions:

You can get the parameter names with describe-stacks, then just pass the parameter with UsePreviousValue=true, as per this example from the help:

–parameters ParameterKey=KeyPairName,UsePreviousValue=true

parse out a bunch of stuff that isn’t necessarily easy to parse in bash

Use jq

You can use the aws cloudformation deploy command instead of create-stack/update-stack.

If you’re updating a stack and you don’t specify a parameter, the deploy command uses the stack’s existing value. For new stacks, you must specify parameters that don’t have a default value.

Well that’s convenient

Create your stack

aws cloudformation create-stack --stack-name CoreDatabaseProd1 --template-url https://s3-ap-southeast-2.amazonaws.com/bucketname/core/database.json --parameters file://parameters/prod/eu-central-1/database.json --on-failure DELETE --capabilities CAPABILITY_IAM --timeout-in-minutes 240 --tags file://tags/prod/eu-central-1/database.json --profile profile-name --region eu-central-1

If you want to quickly get a stacks parameters in a format to pass via file to the create-stack operation

aws cloudformation describe-stacks --stack-name CoreDatabaseProd1 --profile profile-name --region eu-central-1

You could extend the above by providing a --query & using jq + bash output redirection to output straight to file.

–query ‘Stacks.Outputs’ > database.json