I've searched as much as I can and tried loads of different options to get this to work, but I'm completely stuck.
From an Ansible script, I'm creating Cloudformation stacks that consist of a network stack and a instance stack. Within the network stack I create a security group, then when creating the instance I look up the security group and grab the id, so I can pass it to the instance stack.
The problem I'm having is that the security group id needs to be in the format of type "List of String".
The security group id is: sg-c5bfa4bd
so the parameter I pass should look like this: ["sg-c5bfa4bd"]
.
It's the quotes that I'm having problems with.
This is the code that thought would work, with sg_group_id
being passed to the cloudformation template as parameter:
- set_fact:
sg_group_id: '["{{ sg_group_ida }}"]'
But when it hits AWS, the double quotes get converted to single ['sg-c5bfa4bd']
.
If I set the fact to have two double quotes at the begining: '[""{{ sg_group_ida }}"]'
I get double quotes in the parameter on AWS and a double quote at the end: ["sg-c5bfa4bd"]
.
So confused.
Thanks for any help.
David
If
sg_group_ida
is a string sg-c5bfa4bd, then:will produce a list
["sg-c5bfa4bd"]
as value ofsg_group_id
.