Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

312
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda