Reputation: 1174
I have a list of objects (buckets) that I'd like to create with my module
buckets = [
{
name = "my_bucket",
location = "EU"
storage_class = "STANDARD"
force_destroy = false
versioning = true
uniform_bucket_level_access = false
public_bucket = true
labels = {
"app" = "my_app"
}
some fields are required, (like name and location) some are not and I gave them default value in resources if not provided in here; - the full module and everything is operational, but it worked without defining 'type' in variable - so it just took everything, but my question is how do I define that object in variable
block ?
variable "buckets" {
#type = list(object()) #?
type = set(object({
name = string
location = string
storage_class = string
force_destroy = boolean
versioning = boolean
uniform_bucket_level_access = boolean
public_bucket = boolean
labels = object({
string = string # ?
})
}))
}
how would and object look like that has optional fields
Upvotes: 0
Views: 2193
Reputation: 72
https://github.com/hashicorp/terraform/issues/19898 https://discuss.hashicorp.com/t/map-object-with-optional-attributes/6714
It Doesn't seem possible yet apparently..
Upvotes: 1