Create AWS EC2 Instance using Terraform.

Create AWS EC2 Instance using Terraform

What is Terraform ?

Now let’s discuss where it is used?

1.Download Terraform

terraform -v

Configure AWS

aws configure — profile “name”

Build EC2 instance

Configure to terraform.

provider "aws" {
region = "ap-south-1"
profile = "shubham"
}
$ terraform init

Create EC2 instance

resource "aws_instance" "myFirstInstance" {
ami = "ami-0447a12f28fddb066"
instance_type = "t2.micro"
tags = {
Name = "server"
}
}

Output

output "Server_instance"{
value=aws_instance.myFirstInstance
}

How to run code?

$ terraform validate myinstance.tf
$ terraform apply

How to delete all infrastructure?

$ terraform destroy

Conclusion

DevOps Engineer at Mindbowser Inc| www.shubhamrasal.me