Skip to main content

Posts

Showing posts from August, 2018

CREATING EC2 INSTANCE UNDER NEW VPC AND SUBNET USING ANSIBLE

Managing aws resources using Ansible is efficient and reliable. In this document we will create an ec2 instance using Ansible under a new vpc and subnet. For that we will do the following 1) Creating a VPC 2)Creating a subnet 3)Creating an internet gateway and routing table for vpc 3)Creating a security group 4)Creating an ec2 instance Our directory structure for ansible playbook is as follows Here we have an aws role which will execute creating of a new ec2 instance under new vpc and subnet. The main.yaml file under tasks is as follows: Here in our playbook first we will create a VPC.We will specify region,name,cidr-block over here.We will register it as my_vpc. On next step we will save its id which we will use while creating subnet. Similarly we create Internet gateway and routing table to that vpc. Then we will create a n security group allowing traffic through certain ports.Next we created a ssh key pair for our ec2 instance and saved the private key i