Creating ec2 instance using Cloudformation
- We will be installing apache server in ubuntu 22.04
- Things to be created
- Security group with 22 and 80 port opened to all. Refer Here for the changes done
- Things to be figured out
- AMI id of ubuntu22.04:
- key pair to be passed
- instance type to passed
- subnet in which ec2 instance has to be created
- Lets create ec2 based on Refer Here cloudformation spec
- Refer Here for the changes done.
- This created an ec2 instance but it didn’t had public ip address
- Make necessary changes in the template to associate public ip address Refer Here for the changes
- Lets try logging into machine.
- The ssh connection is timed out the reason for that is vpc is private.
- To give internet connectivity to vpc
- create and attach internet gateway
- create a route table with route to internet gateway for anywhere (0.0.0.0/0)
- assoicate this route table to web1 and web2 subnets
- Refer Here for the changes done
- Refer Here for functions