Terraform
Terraform
2️⃣ View Execution Plan terraform plan ✅ Shows what changes Terraform will make. No changes yet.
File Purpose
📌 Remember: terraform.tfstate is NOT created during terraform init. It appears only after terraform
apply.
To use Terraform, create an IAM User with Programmatic Access (Access Key & Secret Key).
1️⃣ Login to AWS as IAM User → Create Access Key. 2️⃣ Configure AWS CLI in VS Code:
aws configure
Run this command in AWS CLI to get the latest Amazon Linux 2 AMI:
📌 What is a Provider?
A provider is what Terraform uses to interact with cloud services (AWS, Azure, GCP, etc.).
provider "aws" {
region = "us-east-1"
}
📌 What is a Resource?
instance_type = "t2.micro"
}
Manually Deleting Terraform will think the resources don’t exist and recreate them. ⚠️
terraform.tfstate Avoid deleting manually!
6️⃣ Terraform Tips & Tricks
📝 Easy Mapping:
✅ Best Practices:
Use terraform destroy before changing regions (to avoid orphaned resources).
provider "aws" {
region = "us-east-1"
instance_type = "t2.micro"