Install terraform on ubuntu and Create EC2 instance on AWS using terraform script

Open terminal and download terraform using the following command:
  1. sudo apt-get update
  2. wget https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_amd64.zip
  3. sudo unzip ./terraform_0.11.13_linux_amd64.zip -d /usr/local/bin/
  4. terraform -v
Now, create terraform script and run the following command to instance:
  1. nano terraform.tf
provider "aws" {
  region     = "region"
  access_key = "accesskey"
  secret_key = "secretkey"
}

resource "aws_instance" "example" {
  ami = "ami-8803e0f0"
  instance_type = "t2.micro"
}
  1. terraform init
  2. terraform plan
  3. terraform apply
Note: Enter yes after apply command.
OUTPUT:
You see that Ec2 instance is running in your AWS Console.

Comments

Popular posts from this blog

Deploy Django website using AWS Elastic Beanstalk CLI in windows

Deployment of Website Using AWS CICD pipeline & Fargate