Hi,
The ec2_vpc
module is used to create/change both VPCs and its subnets.
A with_items
iterator on ec2_vpc
, as expected, will call ec2_vpc
as many times as there are items in the loop.
This means there is no way to add a with_items
to the subnets
parameter inside ec2_vpc
It is possible to create subnets
variable independently from the call to ec2_vpc
, and use that, however I am struggling to create the list I need:
I have something like:
Variables:
- stack: "atlas"
- env: "dev"
- app: "core"
- visibility: "private"
- subnet_parameters:
- cidr: "10.220.220.0/24"
availability_zone: "ap-southeast-2a"
suffix: "A"
- cidr: "10.220.221.0/24"
availability_zone: "ap-southeast-2b"
suffix: "B"
Any idea on how would I be able to generate something like this, from those variables? set_fact
seems as if its not designed for loops?
- module or something else here?
- cidr: "{{ item.cidr }}"
az: "{{ item.availability_zone }}"
resource_tags:
Name: "{{ app }} {{ stack }} {{ env }} {{ item.suffix }} subnet",
stack: "{{ stack }}",
environment: "{{ env }}",
application: "{{ app }}",
visibility: "{{ visibility }}"
with_items: "{{ subnet_parameters }}"
Thanks so much,
Steve