---
- name: Create AWS resources
hosts: all
connection: local
gather_facts: False
vars:
aws_region: ap-south-1
tasks:
- ping:
- name: Create VPC
ec2_vpc:
region: "{{aws_region}}"
cidr_block: 10.0.0.0/16
resource_tags:
Environment: Development
register: vpc
- name: create igw
ec2_vpc_igw:
vpc_id: "{{vpc.vpc.id}}"
region: "{{aws_region}}"
state: present
- name: Create subnets
ec2_vpc_subnet:
region: "{{aws_region}}"
vpc_id: "{{vpc.vpc.id}}"
cidr: "10.0.1.0/24"
resource_tags:
Environment: "Development"
register: subnets
- name: Enable subnet Internet access
ec2_vpc_route_table:
vpc_id: "{{vpc.vpc.id}}"
region: "{{aws_region}}"
tags:
Name: Public
subnets:
- "{{ subnets.subnet.id }}"
routes:
- dest: 0.0.0.0/0
gateway_id: "igw"
- name: Create subnets
ec2_vpc_subnet:
region: "{{aws_region}}"
vpc_id: "{{vpc.vpc.id}}"
cidr: "10.0.2.0/24"
resource_tags:
Environment: "Development"
register: subnetss
- name: Enable subnet Nat
ec2_vpc_route_table:
vpc_id: "{{vpc.vpc.id}}"
region: "{{aws_region}}"
tags:
Name: Private
subnets:
- "{{ subnetss.subnet.id }}"
routes:
- dest: 0.0.0.0/0
gateway_id: "nat"
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/4046310a-3cdd-4063-826e-e5429e00ef72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.