Create a main.tf
file and add the following Terraform configuration
provider "aws" {
region = "us-east-1" # Change to your desired region
}
resource "aws_instance" "aws_ec2_test" {
ami = "ami-08c40ec9ead489470" # Change to your desired AMI
instance_type = "t2.micro"
tags = {
Name = "TerraformTestServerInstance"
}
}
Initialize and Apply
terraform init
Check AWS Credentials
aws configure
Refresh AWS Credentials
aws sts get-caller-identity
Now again execute the below commands
terraform init
terraform apply
Thank you so much for reading
Follow me on LinkedIn to see interesting posts like this : )
Β