Přejít k hlavnímu obsahu
🔒 Režim náhledu. Prvních patnáct lekcí Foundations je zdarma; tato je Pro. Spusťte 7denní trial pro odemčení editoru, AI nápověd a zbytku kurzu. Karta vyžadována, zrušte kdykoli v Dashboard.Spustit 7denní trial →
⚡
← Kurzy›DevOps for Python servicesModul 1 · Docker & Containers›

Infrastruktura jako kód (Terraform)

predict6 / 104
+100 XP
Úkol🌐 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.
Předpověz výstup

Přečti kód pozorně

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 program vypíše? Napiš sem: