How to do it...

Let's look at VPC and other resource creation snippets:

  1. VPC creation example:
    - ec2_vpc:        state: present        cidr_block: 10.0.0.0/16       resource_tags: { "Environment":"Development" }      region: us-west-2
  1. Subnet creation example:
subnets:         - cidr: 172.22.1.0/24            az: us-west-2c            resource_tags: { "Environment":"Dev", "Tier" : "Web" }
  1. Internet Gateway:
internet_gateway: True        route_tables:          - subnets:              - 172.22.2.0/24              - 172.22.3.0/24            routes:              - dest: 0.0.0.0/0                gw: igw
  1. Creating a NAT Gateway:
- name: Create new nat gateway and allocate new EIP.  ec2_vpc_nat_gateway:    state: present    subnet_id: subnet-12345678    wait: yes    region: ap-southeast-2  register: new_nat_gateway
  1. Deleting a VPC:
    - ec2_vpc:      state: absent       vpc_id: vpc-aaaaaaa region: us-west-2 ...

Get AWS Networking Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.