Skip to content
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

Handle template "Default" value #3

Closed
vgunawan opened this issue Dec 1, 2017 · 1 comment
Closed

Handle template "Default" value #3

vgunawan opened this issue Dec 1, 2017 · 1 comment

Comments

@vgunawan
Copy link

vgunawan commented Dec 1, 2017

Currently cfparams will add UserPreviousValue field when parameter is not given in parameters file. Like so:

  {
    "ParameterKey": "ImageTag",
    "UsePreviousValue": true
  },

This is useful during update-stack, however during create-stack the default values are often needed to create stack.

I guess providing switch to do this would be handy such as --use-template-defaults.

@pda
Copy link
Contributor

pda commented Dec 1, 2017

Got that covered, I believe, with --accept-defaults and --no-previous. From one of the use-cases in the README.md:


Creating ECS service CloudFormation stack

Launching the CloudFormation stack for the first time. Accept some defaults from the template, specify all other parameters.

params="$(
  cfparams --template=cfn.yaml --accept-defaults --no-previous \
    Recipient=world ImageTag=v1 Cluster=nanoservices
)"
  • --template loads supported Parameters from a CloudFormation template.
  • --accept-defaults omits keys that have a default in the CloudFormation template.
  • --no-previous means fail if a key has no default in the template and isn't specified on the command line. Without this option, those keys will be auto-filled as "UsePreviousValue": true.

Resulting JSON:

[
  {"ParameterKey": "Recipient", "ParameterValue": "world"},
  {"ParameterKey": "ImageTag", "ParameterValue": "v1"},
  {"ParameterKey": "Cluster", "ParameterValue": "nanoservices"}
]
aws cloudformation create-stack \
  --stack-name=greeting \
  --template-body=file://cfn.yaml \
  --parameters="$params"

@pda pda closed this as completed May 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants