Aws-cli: Cloudformation external parameter file do not support YAML file

Created on 3 Nov 2016  ·  143Comments  ·  Source: aws/aws-cli

I used aws-cli to update my stacks, and want to use an external yaml file (dev.yaml) as parameters file like below:

aws cloudformation update-stack --stack-name test --template-body file://./api-test.yaml --parameters file://./dev.yaml

In dev.yaml, it only has:

---
- ParameterKey: APICacheClusterSize
  ParameterValue: '1.6'

However, I got this Error message when I run the update command above:

Error parsing parameter '--parameters': Expected: '=', received: '-' for input:

---
- ParameterKey: APICacheClusterSize
^
  ParameterValue: '1.6'

If I use JSON file with same context as below, and use it instead of dev.yaml, it works fine:

[
  {
    "ParameterKey": "APICacheClusterSize",
    "ParameterValue": "1.6"
  }
]

So, can the external parameters file for aws cloudformation be YAML file? or will...?

feature-request

Most helpful comment

I'll second this feature request.

All 143 comments

Hi, we currently don't have any plans to support YAML as part of the command line arguments. I will mark this as a feature request as I can see how it might be useful for some people.

The contents of the the file you provide to --parameters is loaded and dumped straight in as an argument so you can only have the file contents be in one of two formats:
Shorthand syntax:
ParameterKey=string,ParameterValue=string,UsePreviousValue=boolean
or JSON syntax:

[
    {
         "ParameterKey": "string",
         "ParameterValue": "string",
         "UsePreviousValue": true|false
     }
]

I'll second this feature request.

I'll second it too

+1

Please. This is critical for us.

+1

absolutely +1

+1 allowing YAML formatted data for --template-body but not for --parameters is awkward

👍

+1

+1

+1

since you can provide a template in yaml, you should be able to provide the parameters in yaml too
i think this feature is a must-have

+1

+100

+1

+100

+1

" https://gist.github.com/mbailey/2f7c878eed123cab6fb125117f35aecc
"
" yamlise - see YAML when editing JSON files in vim.
"
" Created for people with JSON phobia, this should
" only be used when all attempts to master JSON
" have failed. http://www.json.org/
"
" I hope it isn't too late for these folks!
" 'Please. This is critical for us.'
" https://github.com/aws/aws-cli/issues/2275#issuecomment-277829948
"
" Installation
" ============
" 1. Install cfn-flip https://github.com/awslabs/aws-cfn-template-flip
" 2. Include this file in your ~/.vimrc
" 3. vim cloudformation-params.json
" YOU SHOULD NOW SEE THE YAML YOU CRAVE
" 4. :wq
" The file should now contain the JSON Amazon CLI expects
"
:augroup yamlise
: autocmd!
: autocmd BufReadPost,FileReadPost *.json '[,']!cfn-flip
: autocmd BufWritePre,FileWritePre *.json '[,']!cfn-flip
: autocmd FileAppendPre *.json '[,']!cfn-flip
:augroup END

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+999

+1

+1

+1

+1

+2

+1

+1

+1

+1

+1

+1

+1

+10000000

+1

+Inf

+1

+1

+1

+1

+1

Here's a simple workaround using Bash process substitution and cfn-flip:
aws cloudformation ... --parameters file://<(cfn-flip parameters.yml)

+1

+1

++

+0.5

+1

++

+1!

Don't understand why you would have the template in YAML but then the parameters in JSON. Seems an odd omission and would I hope that AWS are working on....please?

+1

+1

Good Morning!

We're closing this issue here on GitHub, as part of our migration to UserVoice for feature requests involving the AWS CLI.

This will let us get the most important features to you, by making it easier to search for and show support for the features you care the most about, without diluting the conversation with bug reports.

As a quick UserVoice primer (if not already familiar): after an idea is posted, people can vote on the ideas, and the product team will be responding directly to the most popular suggestions.

We’ve imported existing feature requests from GitHub - Search for this issue there!

And don't worry, this issue will still exist on GitHub for posterity's sake. As it’s a text-only import of the original post into UserVoice, we’ll still be keeping in mind the comments and discussion that already exist here on the GitHub issue.

GitHub will remain the channel for reporting bugs.

Once again, this issue can now be found by searching for the title on: https://aws.uservoice.com/forums/598381-aws-command-line-interface

-The AWS SDKs & Tools Team

This entry can specifically be found on UserVoice at: https://aws.uservoice.com/forums/598381-aws-command-line-interface/suggestions/33168310-cloudformation-external-parameter-file-do-not-supp

+1

Based on community feedback, we have decided to return feature requests to GitHub issues.

+1

+1

+1

+100

+1

+1

+1

+1
and +1000 for more consistency overall please ;)

+1

This issue is 2 years old ;_;

@matthewflannery nope, it's only 587 days actually.

+1

@Yaowenjie 587/365 = 1.608 ~ 2 years

+1

plus 11!1!1one!!1!11

:+1:

:heavy_plus_sign: :100:

👍

+1

there are two months left for the second-anniversary celebration of this issue, folks! 👨‍👩‍👧‍👦🎉🎉🎊🎊👨‍👨‍👧‍👦

Because my team are used to YAML (all our templates are in YAML) I have some shell automation that turns a YAML file into a json file, then passes that to CF. That shows (to me at least) how wanted this feature is - having customers build their own automation around basic functionality like this isn't an answer.

Also, we should note that the whole parametersKey/ParamaterValue way of working for CloudFormation is stupid.

Could we have the CloudFormation template in YAML and provide parameters file in JSON ?

@Yashswarnkar Yes - you can have the template in YAML and the parameters in JSON. This issue is because the parameters can only be in JSON - YAML files are not supported despite the template being in YAML.

+1 Really would like to be able to add comments to my parameters files and run them from the CLI. Any plans yet to add .yaml support for the create-stack CLI command with --parameters to support yaml?

Any ETA for this feature?

+1

Almost 2 years and still no yaml for parameters... :(

+1

+1

+1

With SSM now available with secure strings and ways to decode them, I am entertaining the idea of running a script to place the variables into the AWS account, and then to reference them from the cloudformation template... Anybody have other ideas such as this?

As per comments above, you could use cfn-flip
https://github.com/awslabs/aws-cfn-template-flip

In bash - Display parameters.yaml as a json file with <( ) operator

pip install cfn_flip

cat <(cfn-flip parameters.yaml)

Use, with <( ) in the cli command

aws cloudformation update-stack --stack-name test --template-body file://./api-test.yaml --parameters file://<(cfn-flip parameters.yaml)

+100

This is obviously a feature in high demand - why has there been no movement on this despite what looks like hundreds of people requesting it?

+1
REAL use case, is where having to specify JSON within a parameter, in which case JSON is a nightmare with having to escape quotes...

[
    {
        "ParameterKey": "DistributionJSON",
        "ParameterValue": "{\"Account_ID_1\":\"region_1,region_2\",\"Account_ID_2\":\"region_1\"}"
    }
]

Compared to:

- ParameterKey: DistributionJSON
  ParameterValue: '{"Account_ID_1":"region_1,region_2","Account_ID_2":"region_1"}'

Well? No more updates?

Well? No more updates?

Calm down, it's only January 2019

Hey, how are these guys with merging in PRs?

I'd consider writing this if I knew the team regularly merged in PRs from those outside their org.

No idea. I figure there’s enough demand for this, they will implement it eventually.

this should maybe just stay open forever and everyone that is on it can all be friends and have a conference every year called 'Payameter Fam' (as in yaml parameter fam) where we all get together and discuss our anti-yaml trauma.

+1

👍

+1

+1

3 years, 90% of APIs using YAML, a lot of annoying +1 and AWS scratching its balls...

I would really like yaml simply to use comments for the config files / uncomment items/etc

+1

It's June 2019, I don't understand why AWS is still not resolving this issue. They are hiring so many people every year

Come on Really? Lets get this moving

+1

+1

+1

+1

+1

+1

+1

waiting... waiting...

still waiting!

Still parameters are Json only?

This issue is old enough to start preschool.

I'll be at re:Invent 2019 if anyone wants to bond over this issue and talk shit to Jeff Barr, et. al on twitter.

This would be lovely

+1

+1

+1

+1
just hit into this rock, can I get YAML parameters support please?
My current project love YAML (I'm not:) )

Can you please add XML support too? I can't submit this via SOAP. AWS support is essential in Windows Forms.

+1

+1

+1

Any updates :/ ?

+1

+1
id like to be be able to comment in my parameter file by splitting cloudformation upgradable params and non-upgradable.
eg. i tried upgrading my my snapshot id of a volume.
-> Volume properties other than AutoEnableIO, type, size, and IOPS cannot be updated. Change the properties back to previous values and update the stack again.

Was trying to create a stack with the following command: aws cloudformation create-stack --stack-name myfirsttest --region us-west-2 --template-body file://testcfn.yml
But got the following error message:
Error parsing parameter '--template-body': Unable to load paramfile file://testcfn.yml: [Errno 2] No such file or directory: 'testcfn.yml'

My testcfn.yml file is as follows:
Description: > Vritika / Udacity project This template deploys a VPC Resources: UdacityVPC: Type: AWS::EC2::VPC Properties: CidrBlock: 10.0.0.0/16 EnableDnsHostnames: true

› aws ssm get-parameters-by-path help                                                                               

# ...

SYNOPSIS
            get-parameters-by-path
          --path <value>
          [--recursive | --no-recursive]
          [--parameter-filters <value>]
          [--with-decryption | --no-with-decryption]
          [--cli-input-json | --cli-input-yaml]
          [--starting-token <value>]
          [--page-size <value>]
          [--max-items <value>]
          [--generate-cli-skeleton <value>]
          [--cli-auto-prompt <value>]

# ...

       --generate-cli-skeleton  (string)  Prints  a  JSON skeleton to standard
       output without sending an API request. If provided with no value or the
       value input, prints a sample input JSON that can be used as an argument
       for --cli-input-json. Similarly, if provided yaml-input it will print a
       sample  input  YAML that can be used with --cli-input-yaml. If provided
       with the value output, it validates the command inputs  and  returns  a
       sample output JSON for that command.

Yay, yaml support!!!

› aws ssm get-parameters-by-path --path "/foo/bar/" --recursive --generate-cli-skeleton yaml-input
Path: ''  # [REQUIRED] The hierarchy for the parameter.
Recursive: true # Retrieve all parameters within a hierarchy.
ParameterFilters: # Filters to limit the request results.
- Key: ''  # [REQUIRED] The name of the filter.
  Option: '' # For all filters used with DescribeParameters, valid options include Equals and BeginsWith.
  Values: # The value you want to search for.
  - ''
WithDecryption: true # Retrieve all parameters in a hierarchy with their value decrypted.
MaxResults: 0 # The maximum number of items to return for this call.
NextToken: '' # A token to start the list.

Is this still not a thing?? Or Did I miss that it is somewhere?

For anyone interested in using .yaml in their parameters please refer to this
https://github.com/realestate-com-au/stackup

I think AWS should be knocking on real estates door to purchase this code and move it into their IP.....

+1

Not a big fan of hacky ways to solve issues, as hacky becomes messy pretty fast.
But for anyone interested in doing this with params file in their test env.

s3template.yml

AWSTemplateFormatVersion: '2010-09-09'
Description: create a single S3 bucket
Parameters: 
  BucketName:
    Description: Unique name for bucket.
    Type: String
  AccessControl:
    Description: Access Control of the bucket
    Type: String
    AllowedValues:
      - Private
      - PublicRead

Resources:
  SampleBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: !Ref BucketName
      AccessControl: !Ref AccessControl

s3template.params

BucketName=sample-unique-bucket-123456
AccessControl=Private

Run :
aws cloudformation deploy --template-file ./s3template.yml --stack-name sample-testbucket --region us-east-1 --parameter-overrides $(cat s3template.params)

+1 for params files as YAML. Why force someone to mix markups?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rahul003 picture rahul003  ·  3Comments

ronaldpetty picture ronaldpetty  ·  3Comments

maanbsat picture maanbsat  ·  3Comments

ypant picture ypant  ·  3Comments

KimberleySDU picture KimberleySDU  ·  3Comments