PENDING CLEANUP
Module 8: Terraform Assignment - 2
Tasks To Be Performed:
- Destroy the previous deployment
 - Create a new EC2 instance with an Elastic IP
 
Step 1: Destroying infrasctructure (EC2) created in Assignment 1 – Terraform

Step 2: New instance with Elastic IP
will switch to us-east-1
so we take the main.tf from Assignment 1 – Terraform and modify it
provider "aws" {
  region = "us-east-2" # Ohio region
}
resource "aws_instance" "example" {
  ami           = "ami-06d4b7182ac3480fa" # AmazonLinux
  instance_type = "t2.micro"
  subnet_id = "subnet-01384a93bc22b2937"
  tags = {
    Name = "ExampleEC2"
  }
}
resource "aws_eip" "example" {
  instance = aws_instance.example.id
  domain   = "vpc"
}- The 
aws_eipresource creates an Elastic IP. - The 
instanceattribute in theaws_eipresource is set toaws_instance.example.id, which associates the EIP with your EC2 instance. 
terraform apply

my instance has Elastic IP
