I am creating a VPC in AWS using Ansible. The next playback is in progress.
- name: create vpc with multi-az subnets ec2_vpc: region: "{{ region }}" cidr_block: "{{ vpc_cidr_block }}" resource_tags: '{"Name":"{{ prefix }}_vpc"}' subnets: - cidr: "{{ vpc_cidr_subnet_public_0 }}" az: "{{ region }}{{ availability_zone_0 }}" resource_tags: '{"Name":"{{ prefix }}_subnet_public_0", "Class":"web", "Partner":prefix }' - cidr: "{{ vpc_cidr_subnet_private_0 }}" az: "{{ region }}{{ availability_zone_0 }}" resource_tags: '{"Name":"{{ prefix }}_subnet_private_0", "Class":"db", "Partner":prefix }' - cidr: "{{ vpc_cidr_subnet_private_1 }}" az: "{{ region }}{{ availability_zone_1 }}" resource_tags: '{"Name":"{{ prefix }}_subnet_private_1", "Class":"db", "Partner":prefix }' internet_gateway: yes route_tables: - subnets: - "{{ vpc_cidr_subnet_public_0 }}" routes: - dest: 0.0.0.0/0 gw: igw wait: yes register: vpc
The first time this creates everything perfectly. The second time, I expect it to do nothing, since everything has been created, but the public subnet has been updated to private.
Why? What am I doing wrong?
[UPDATE]
Here are the variables:
It’s also easy to clarify what’s going on. All resource tags of one subnet (public) are overwritten using tags of another subnet (private).
amazon-web-services ansible
Ryan-neal mes
source share