Detect and fix discrepancies between your Terraform code, state, and actual infrastructure.
Create resources that we'll intentionally drift.
mkdir -p ~/terraform-practice/lesson-403cd ~/terraform-practice/lesson-403cat > main.tf << 'EOF'
terraform {
required_providers {
local = {
source = "hashicorp/local"
version = "~> 2.4"
}
}
}
resource "local_file" "app_config" {
filename = "${path.module}/app.conf"
content = <<-EOT
server_name = production
port = 8080
debug = false
max_connections = 100
EOT
}
resource "local_file" "db_config" {
filename = "${path.module}/database.conf"
content = <<-EOT
host = db.example.com
port = 5432
pool_size = 10
EOT
}
EOFWe're creating two configuration files. In real scenarios, these would be cloud resources like VMs, databases, or security groups.
main.tf with two local_file resources.