Install terraform on ubuntu and Create EC2 instance on AWS using terraform script
Open terminal and download terraform using the following command:
- sudo apt-get update
- wget https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_amd64.zip
- sudo unzip ./terraform_0.11.13_linux_amd64.zip -d /usr/local/bin/
- terraform -v
Now, create terraform script and run the following command to instance:
- nano terraform.tf
provider "aws" {
region = "region"
access_key = "accesskey"
secret_key = "secretkey"
}
resource "aws_instance" "example" {
ami = "ami-8803e0f0"
instance_type = "t2.micro"
}
- terraform init
- terraform plan
- terraform apply
Note: Enter yes after apply command.
OUTPUT:
You see that Ec2 instance is running in your AWS Console.

Comments
Post a Comment