Not sure if something changed or i'm doing something wrong, but i could have sworn this used to work.
Basically if I only specify one bucket name, a few of the outputs fail. 2 or more, plan appears to be successful.
Realise there is a module for single bucket creation but wanted to use this module as there will be an eventual need to add more buckets with similar specifications
source = "terraform-google-modules/cloud-storage/google"
version = "~> 1.3"
project_id = var.project_id
names = ["test1","test2"]
#names = [for name in var.bucket_names : "${local.resource_type_code}-${name}-${random_id.bucket-postfix.hex}"]
location = var.location
storage_class = var.storage_class
prefix = var.feature_code
versioning = {
first = true
}
}
+ resource "google_storage_bucket" "buckets" {
+ bucket_policy_only = true
+ force_destroy = false
+ id = (known after apply)
+ labels = {
+ "name" = "test1"
}
+ location = "AUSTRALIA-SOUTHEAST1"
+ name = "test1"
+ project = "shareddata-dev-af5e"
+ self_link = (known after apply)
+ storage_class = "STANDARD"
+ url = (known after apply)
+ versioning {
+ enabled = false
}
}
# module.as-gcs-buckets.module.gcs_buckets.google_storage_bucket.buckets[1] will be created
+ resource "google_storage_bucket" "buckets" {
+ bucket_policy_only = true
+ force_destroy = false
+ id = (known after apply)
+ labels = {
+ "name" = "test2"
}
+ location = "AUSTRALIA-SOUTHEAST1"
+ name = "test2"
+ project = "shareddata-dev-af5e"
+ self_link = (known after apply)
+ storage_class = "STANDARD"
+ url = (known after apply)
+ versioning {
+ enabled = false
}
}
source = "terraform-google-modules/cloud-storage/google"
version = "~> 1.3"
project_id = var.project_id
names = ["test1"]
#names = [for name in var.bucket_names : "${local.resource_type_code}-${name}-${random_id.bucket-postfix.hex}"]
location = var.location
storage_class = var.storage_class
prefix = var.feature_code
versioning = {
first = true
}
}
on .terraform/modules/as-gcs-buckets.gcs_buckets/terraform-google-modules-terraform-google-cloud-storage-dfbab2e/outputs.tf line 19, in output "bucket":
19: value = google_storage_bucket.buckets[0]
|----------------
| google_storage_bucket.buckets is empty tuple
The given key does not identify an element in this collection value.
Error: Invalid index
on .terraform/modules/as-gcs-buckets.gcs_buckets/terraform-google-modules-terraform-google-cloud-storage-dfbab2e/outputs.tf line 24, in output "name":
24: value = google_storage_bucket.buckets[0].name
|----------------
| google_storage_bucket.buckets is empty tuple
The given key does not identify an element in this collection value.
Error: Invalid index
on .terraform/modules/as-gcs-buckets.gcs_buckets/terraform-google-modules-terraform-google-cloud-storage-dfbab2e/outputs.tf line 29, in output "url":
29: value = google_storage_bucket.buckets[0].url
|----------------
| google_storage_bucket.buckets is empty tuple
The given key does not identify an element in this collection value.
Error: Invalid function argument
on .terraform/modules/as-gcs-buckets.gcs_buckets/terraform-google-modules-terraform-google-cloud-storage-dfbab2e/outputs.tf line 39, in output "names":
39: value = zipmap(var.names, slice(google_storage_bucket.buckets[*].name, 0, length(var.names)))
|----------------
| var.names is list of string with 1 element
Invalid value for "end_index" parameter: end index must not be greater than
the length of the list.
Error: Invalid function argument
on .terraform/modules/as-gcs-buckets.gcs_buckets/terraform-google-modules-terraform-google-cloud-storage-dfbab2e/outputs.tf line 44, in output "urls":
44: value = zipmap(var.names, slice(google_storage_bucket.buckets[*].url, 0, length(var.names)))
|----------------
| var.names is list of string with 1 element