In this challenge, you will encounter a Terraform project meant to set up resources in AWS. However, there are discrepancies between the Terraform code and the actual cloud infrastructure, known as "drift". Your task is to identify, rectify, and consolidate the Terraform configurations with the actual state in AWS.
- Understand the current infrastructure setup using Terraform configurations.
- Detect drifts in the infrastructure by assessing the differences between the Terraform state and real-world resources.
- Modify the Terraform configurations to align with the desired state.
- Ensure a fully functional, secure, and optimized infrastructure setup.
my_challenge_project/
├── ec2/
│ ├── main.tf
│ ├── variables.tf
├── rds/
│ ├── main.tf
│ ├── variables.tf
├── vpc/
│ ├── main.tf
│ ├── variables.tf
├── main.tf
├── backend.tf
└── provider.tf
main
: The base configuration.feature/vpc-enhancement
: Includes updates related to VPC.feature/db-update
: Involves RDS instance updates.feature/ec2-optimization
: Contains changes related to EC2 instances.hotfix/security
: Addressing some security fixes.feature/monitoring
: Introduces monitoring with CloudWatch.
- Clone the repository and start with the
main
branch. - Setup the infrastructure using
terraform init
andterraform apply
. - Switch between branches and attempt to apply each feature/hotfix.
- While navigating each branch, you must:
- Identify hidden issues in the Terraform configurations.
- Reconcile Terraform's state with AWS by rectifying the discrepancies.
- Use
terraform plan
to detect drifts andterraform apply
to reconcile them.
- Ensure that the final infrastructure is functional, secure, and optimized.
- Ability to identify hidden issues in each branch.
- Correct use of
terraform plan
andterraform apply
to detect and fix drifts. - Fully functional, secure, and optimized final infrastructure.
- Efficiency in reconciling Terraform state with real-world infrastructure.
- Always review the Terraform configurations thoroughly.
- Use
terraform plan
judiciously to identify discrepancies. - Communication is key. If you're collaborating, ensure you're on the same page with team members.
Drift management in Terraform is essential for maintaining infrastructure consistency. This challenge simulates real-world scenarios where minor oversights can lead to significant infrastructure problems. It aims to enhance your skills in managing and rectifying drifts in Terraform projects.
Good luck, and happy terraforming!