Create resources keyed by map/set members.
Section: Meta-arguments
Use for_each
hcl
hcl
resource "aws_s3_bucket" "logs" {
for_each = toset(["app","elb","audit"])
bucket = "${var.prefix}-${each.key}"
}Explanation
Create resources keyed by map/set members.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Meta-arguments