This is a basic Terraform project setup for AWS infrastructure management.
- Install Terraform: Download from terraform.io
- AWS CLI: Install and configure with your credentials
- AWS Account: Ensure you have appropriate permissions
terraform_setup/
├── main.tf # Main Terraform configuration
├── variables.tf # Input variables
├── outputs.tf # Output values
├── terraform.tfvars.example # Example variable values
├── .gitignore # Git ignore rules for Terraform
└── README.md # This file
Copy the example variables file and customize it:
cp terraform.tfvars.example terraform.tfvarsEdit terraform.tfvars with your desired values.
Make sure your AWS credentials are configured:
aws configureOr set environment variables:
export AWS_ACCESS_KEY_ID="your-access-key"
export AWS_SECRET_ACCESS_KEY="your-secret-key"
export AWS_DEFAULT_REGION="us-west-2"terraform initterraform planterraform applyterraform destroyThis basic configuration creates:
- A VPC with DNS support
- An Internet Gateway
- A public subnet in the first available AZ
- Proper tagging for all resources
- Modify
variables.tfto add new variables - Update
main.tfto add new resources - Add new output values in
outputs.tf - Use modules for reusable components
- Always run
terraform planbeforeapply - Use version control for your Terraform code
- Keep sensitive data in
terraform.tfvars(not committed to git) - Use remote state for team collaboration
- Tag all resources consistently
- Ensure AWS credentials are properly configured
- Check that your AWS account has necessary permissions
- Verify the region and availability zones are correct
- Review Terraform logs for detailed error messages