Terraform_VPC What Do We Achieve with This?
- Create vpc with CIDR block 10.0.0.0/16
- Create public subnet in above vpc with CIDR block 10.0.1.0/24
- Create private subnet in above vpc with CIDR block 10.0.2.0/24
- Create and Assign Internet Gateway and Public Route Table to the Public Subnet
- Create and Assign Private Route Table to the Private Subnet
- Create the Security Group for the Public and Private Subnet
- Create SSH Key pair for the EC2 instances
- Create EC2 instances and install Apache on webserver
Implementation:
- Download the cloud.tf and vars.tf file.
- Replace the access_key, secret_key and key file values in the files.
- Generate the .PEM, .ppk files and place in the same location as cloud.tf and vars.tf.
- On a linux machine, execute the following
ssh-keygen -y -f .pem - Copy the output and paste it in a empty file and this will be <Your_Key>. Maintain this in the same directory as other .tf files.
- Execute below commands.
terraform plan
terraform apply -auto-approve