Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

315
Views
AWS CLI- What is the syntax for assigning multiple values on a parameter

For example, I have this CF template that ask for these parameters

----- cftemplate.yaml -----
...
Parameters:
  **Subnet:
    Description: Subnet for the Instance
    Type: 'AWS::EC2::Subnet::Id'
  SecurityGroups: 
    Description: Security Group for Instance
    Type: 'List<AWS::EC2::SecurityGroup::Id>'**
...
Resources:
 EC2Instance:
   Type: AWS::EC2::Instance
   Properties:
...
    **SubnetId: !Ref Subnet
    SecurityGroupIds: !Ref SecurityGroups**
...
----- cftemplate.yaml -----

For me to deploy the stack, I use this command:

aws cloudformation create-stack --stack-name StackName --template-body file://cftemplate.yaml --parameters file://params.json

Where params.json contains:

----- params.json ----- 
[
        {
            "ParameterKey":"Subnet",
            "ParameterValue":"subnet-11111111"
        },
        {
            "ParameterKey":"SecurityGroups",
            "ParameterValue":"sg-111111111",
            "ParameterValue":"sg-222222222"
        } 
]
----- params.json -----

Now, my goal is to eliminate the use of .json file. Does anyone know the shorthand syntax of the command that should achieve the same effect as above command? Can't seem to find this on the documentations online. Thanks in advance!

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

The command line equivalent would be (little re-formatted for clarify):

aws cloudformation create-stack \
    --stack-name StackName \
    --template-body file://cftemplate.yaml \
    --parameters ParameterKey=Subnet,ParameterValue=subnet-11111111 ParameterKey=SecurityGroups,ParameterValue=sg-111111111\\,sg-222222222

In the above attention to spaces and commas are important.

I verified the command using my own parameters and my sandbox account:

aws cloudformation create-stack --stack-name StackName --template-body file://instance.yaml --parameters ParameterKey=Subnet,ParameterValue=subnet-0ae6ce0f9bbf52251 ParameterKey=SecurityGroups,ParameterValue=sg-06d2a3e9c8aa99620\\,sg-004d23d188ec1146f

which is correct and results in starting the process of deploying the stack:

{
    "StackId": "arn:aws:cloudformation:us-east-1:xxxxxx:stack/StackName/61fbacd0-d3b0-11ea-970a-0ad23187ddb2"
}
over 4 years ago · Santiago Trujillo Report

0

you might want to take a look at the rain cli. It's developed but someone from the cloudformation team and it's much better than the aws cli.

https://github.com/aws-cloudformation/rain

over 4 years ago · Santiago Trujillo Report

0

From the cli documentation,

$ aws cloudformation create-stack help

...

"--parameters" (list)

   A list of "Parameter" structures that specify input parameters for
   the stack. For more information, see the Parameter data type.

Shorthand Syntax:

   ParameterKey=string,ParameterValue=string,UsePreviousValue=boolean,ResolvedValue=string ...

JSON Syntax:

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

...

where the list elements are separated by space.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!