Przejdź do treści głównej
🔒 Tryb podglądu. Pierwszych piętnaście lekcji Foundations jest darmowych; ta jest Pro. Rozpocznij 7-dniowy trial, aby odblokować edytor, podpowiedzi AI i resztę kursu. Wymagana karta, anulujesz w dowolnym momencie w Dashboard.Rozpocznij 7-dniowy trial →
⚡
← Kursy›DevOps for Python servicesModuł 1 · Doker i kontenery›

Infrastruktura jako kod (Terraforma)

predict6 / 104
+100 XP
Zadanie🌐 shown in EN
📝 **Task:** The snippet models what `terraform plan` does: it diffs the state against the desired HCL. Predict the exact summary line it prints for the scenario above. 📋 Implement the function above. Tests run automatically. 💡 **Hint:** Re-read the theory if you get stuck.
Przewiduj wynik

Przeczytaj kod uważnie

state = {
    "aws_s3_bucket.uploads": {"bucket": "myapp-uploads-prod"},
    "aws_lambda_function.image_resize": {"runtime": "python3.11"},
    "aws_iam_role.lambda_exec": {"name": "lambda-exec"},
}
desired = {
    "aws_s3_bucket.uploads": {"bucket": "myapp-uploads-prod"},
    "aws_lambda_function.image_resize": {"runtime": "python3.12"},
    "aws_cloudwatch_log_group.lambda_logs": {"name": "/aws/lambda/image-resize"},
}

add = [r for r in desired if r not in state]
destroy = [r for r in state if r not in desired]
change = [r for r in desired if r in state and desired[r] != state[r]]

print(f"Plan: {len(add)} to add, {len(change)} to change, {len(destroy)} to destroy.")

Co wypisze program? Napisz tutaj: