Create and Manage EC2 as Infrastructure as Code with Terraform
Step1 :Download and Install terraform from https://www.terraform.io/downloads.html
Step2 :Verify that the installation worked by opening a new terminal
terraform -help
Step3 : Download and install AWS CLI from https://awscli.amazonaws.com/AWSCLIV2.msi
Step4 :Configure the AWS CLI from your terminal,Follow the prompts to input your AWS Access Key ID and Secret Access Key.
aws configure
Step 5:create a file with .tf extention in any folder ie(c:/sunil/main.tf)
provider "aws" {
profile = "default"
region = "us-west-2"
}
resource "aws_instance" "example" {
ami = "ami-830c94e3"
instance_type = "t2.micro"
tags = {
Name = "ExampleInstance"
}
}
Step 6: Initialize the directory
Initializing a configuration directory downloads and installs the providers defined in the configuration, which in this case is the aws
provider.
terraform init
Step 7:Create infrastructure
terraform apply
No Comments Yet!!