- Install Terraform
- Install AWS CLI
- Install VS Code
- (Recommended) Install VS Code extension: HashiCorp Terraform
- Open terminal and run:
aws configure
- Enter:
- Access Key
- Secret Key
- Region (example:
ap-south-1) - Output format:
json
- Run:
mkdir terraform-vpccd terraform-vpccode .
Inside the folder create these files:
provider.tfmain.tfvariables.tfoutputs.tfREADME.md
- Add provider configuration in
provider.tf - Add VPC + subnet + IGW + NAT + route table resources in
main.tf - Add variables in
variables.tf - Add outputs in
outputs.tf
Run these commands one by one:
terraform initterraform fmtterraform validateterraform planterraform apply
Go to:
- AWS Console → VPC Dashboard Check:
- VPC created
- Public + Private subnet created
- IGW attached
- NAT Gateway running
- Route tables linked correctly
When done practice:
terraform destroy
- NAT Gateway costs money → always destroy after practice
- Don’t upload AWS keys or
.tfstatefiles to GitHub