Tuesday, July 25, 2023

How to Create / launch AWS EC2 instance using Terraform ?

MyFirst-EC2.tf



####Define credential to connect with providers


provider "aws" {

    region = "us-east-1"

    access_key = "Put-Your-Access_Key"

    secret_key = "Put-Your-Secret_Key"

  

}



#### Create Resource i.e. EC2 


resource "aws_instance" "MyEc2" {

 ami = "ami-05548f9cecf47b442"  

 instance_type = "t2.micro"


 

}





Terraform commands 


terraform init
terraform plan
terraform apply

No comments:

Post a Comment