hard20 pts · first answer countsterraforminfrastructure-as-code
count vs for_each in Terraform
You create three S3 buckets using count over the list ["logs", "images", "backups"]. You remove "logs" from the list. What does terraform plan show, and how do you avoid it?
resource "aws_s3_bucket" "b" {
count = length(var.names)
bucket = "acme-${var.names[count.index]}"
}Discussion 0
Join free to post in the discussion.
Related questions
- What terraform plan doesCloud Engineer
- What a Terraform output doesCloud Engineer
- What OpenTofu isCloud Engineer
- Why remote state needs lockingCloud Engineer
- Renaming a resource without recreating itCloud Engineer
- Avoiding downtime on forced replacementCloud Engineer
- Detecting drift from console changesCloud Engineer
- for_each keys unknown until applyCloud Engineer