This project contains infrastructure defined using Terraform, organized into two independent environments: dev and prod. Each environment creates its own VPC and EKS cluster.
.
├── .gitignore
├── README.md
└── envs
├── dev
│ ├── backend.tf
│ ├── locals.tf
│ ├── main.tf
│ ├── terraform.tfvars
│ └── variables.tf
└── prod
├── backend.tf
├── locals.tf
├── main.tf
├── terraform.tfvars
└── variables.tfEach folder under envs/ represents an isolated Terraform environment:
dev/ → Development infrastructure
prod/ → Production infrastructure
Generate AWS credentials and export them as variables
export AWS_ACCESS_KEY_ID="access_key"
export AWS_SECRET_ACCESS_KEY="secret_key"
export AWS_DEFAULT_REGION="us-east-1"The backend.tf file in each environment contains a placeholder bucket name for storing the Terraform state.
You must replace the placeholder with your actual bucket:
terraform {
backend "s3" {
bucket = "<YourBucketName>-terraform-tfstate"
key = "terraform.tfstate"
region = "us-east-1"
}
}Go into the environment you want to deploy (dev or prod):
- Initialize Terraform
terraform init --upgrade- Validate configuration
terraform validate- Check code formatting
terraform fmt -check -diff- Preview execution plan
terraform plan- Apply changes
terraform apply