Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

314
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda