- Separate configurations for dev, staging, and prod
- Environment-specific variables
- Isolated state files
- Different resource sizes per environment
- Common Module: Shared resources and IAM configurations
- EC2 Module: Instance and security group management
- S3 Module: Storage bucket with security features
- VPC Module: Network infrastructure and routing
- Resource Sizing: t2.micro instances
- Network: 10.0.0.0/16 CIDR
- Purpose: Feature development and testing
- Minimal resource allocation
- More permissive security
- Resource Sizing: t2.small instances
- Network: 10.1.0.0/16 CIDR
- Purpose: Pre-production testing
- Production-like configuration
- Similar security to production
- Resource Sizing: t2.medium instances
- Network: 10.2.0.0/16 CIDR
- Purpose: Live workloads
- Maximum resource allocation
- Strict security measures
- Remote state management
- VPC with public/private subnets
- EC2 instances for web and application servers
- S3 buckets for storage
- IAM roles and policies
- Network isolation
- Security groups
- IAM role-based access
- Encryption at rest
- Public access blocking
- Environment-specific sizing
- Expandable CIDR ranges
- Modular design
- Resource customization
cd environments/<env>
terraform initterraform planterraform applyterraform destroyNOTE: Resource Destruction Auto-Approve is NOT recommended in production environments.
terraform destroy --auto-approveWe do this using the -target flag provided by resource type and name of the resource.
terraform destroy -target=RESOURCE_TYPE.RESOURCE_NAME- Independent state files
- Separate variable sets
- Environment-specific tags
- Modular structure
- DRY (Don't Repeat Yourself) principles
- Clear separation of concerns
- Environment isolation
- Least privilege principle
- Network segmentation
- Resource isolation
- Access controls
- Encryption
- Consistent naming
- Clear documentation
- Version control
- State management
- Environment separation
- Remote backend (prod)
- State locking
- Backup management
- Environment-specific values
- Consistent naming
- Clear documentation
- Default values
- Resource identifiers
- Network information
- Access details