---
- name: Create AWS subnets (public)
  ec2_vpc_subnet:
    az: "{{ item.az }}"
    cidr: "{{ item.cidr }}"
    region: "{{ aws_region }}"
    state: present
    vpc_id: "{{ vpc.vpc.id }}"
  with_items:
    - cidr: "{{ subnets_public_cidr.0 }}"
      az: "{{ vpc_subnet_azs.0 }}"
    - cidr: "{{ subnets_public_cidr.1 }}"
      az: "{{ vpc_subnet_azs.1 }}"
    - cidr: "{{ subnets_public_cidr.2 }}"
      az: "{{ vpc_subnet_azs.2 }}"
  retries: 3
  delay: 3
  register: subnet_public

- name: Create AWS subnets (private)
  ec2_vpc_subnet:
    az: "{{ item.az }}"
    cidr: "{{ item.cidr }}"
    region: "{{ aws_region }}"
    state: present
    vpc_id: "{{ vpc.vpc.id }}"
  with_items:
    - cidr: "{{ subnets_private_cidr.0 }}"
      az: "{{ vpc_subnet_azs.0 }}"
    - cidr: "{{ subnets_private_cidr.1 }}"
      az: "{{ vpc_subnet_azs.1 }}"
    - cidr: "{{ subnets_private_cidr.2 }}"
      az: "{{ vpc_subnet_azs.2 }}"
  retries: 3
  delay: 3
  register: subnet_private
