I'm looking for a way to dynamically create AWS S3 buckets by looping on two list(string) type variables. This is what I have so far:
variable "network" {
type = list(string)
default = ["blue", "green", "orange"]
}
variable "type" {
type = list(string)
default = ["ClientA", "ClientB"]
}
resource "aws_s3_bucket" "this" {
for_each = var.type
content {
bucket = "${each.key}-${var.network}.mysite.com"
tags = local.tags
}
}
The problem is that I'm not sure how to also get it to loop through var.network. Ideally it should create the following buckets from the example above:
ClientA-blue.mysite.com
ClientA-green.mysite.com
ClientA-orange.mysite.com
ClientB-blue.mysite.com
ClientB-green.mysite.com
ClientB-orange.mysite.com
Does anybody know how I might achieve this?