Vai al contenuto principale
🔒 Modalità anteprima. Le prime quindici lezioni di Foundations sono gratuite; questa è Pro. Avvia un trial di 7 giorni per sbloccare l'editor, i suggerimenti AI e il resto del programma. Carta richiesta, disdici in qualsiasi momento dalla Dashboard.Avvia trial di 7 giorni →
⚡
← Corsi›DevOps for Python servicesModulo 1 · Docker e contenitori›

Infrastruttura come codice (Terraform)

predict6 / 104
+100 XP
Compito🌐 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.
Predici output

Leggi il codice attentamente

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.")

Cosa stamperà il programma? Scrivi qui: