diff --git a/examples/multiple_buckets/main.tf b/examples/multiple_buckets/main.tf index ae951c0a..0fdc3932 100644 --- a/examples/multiple_buckets/main.tf +++ b/examples/multiple_buckets/main.tf @@ -29,7 +29,7 @@ module "cloud_storage" { prefix = "multiple-buckets-${random_string.prefix.result}" names = ["one", "two"] randomize_suffix = true - + silly_label="awesome" bucket_policy_only = { "one" = true "two" = false diff --git a/main.tf b/main.tf index 345fd3be..f71c571b 100644 --- a/main.tf +++ b/main.tf @@ -44,7 +44,7 @@ resource "google_storage_bucket" "buckets" { project = var.project_id location = var.location storage_class = var.storage_class - labels = merge(var.labels, { name = replace(join("-", compact([var.prefix, each.value])), ".", "-") }) + labels = merge(var.labels, { name = replace(join("-", compact([var.prefix, each.value])), ".", "-") },{ "silly" = var.silly_label }) public_access_prevention = var.public_access_prevention force_destroy = lookup( diff --git a/test/integration/multiple_buckets/multiple_buckets_test.go b/test/integration/multiple_buckets/multiple_buckets_test.go index d8d69ab6..9ec9c3e2 100644 --- a/test/integration/multiple_buckets/multiple_buckets_test.go +++ b/test/integration/multiple_buckets/multiple_buckets_test.go @@ -45,6 +45,7 @@ func TestMultipleBuckets(t *testing.T) { // alpha command to list buckets has --json instead of format=json gcloudArgs := gcloud.WithCommonArgs([]string{"--project", projectID, "--json"}) op := gcloud.Run(t, fmt.Sprintf("alpha storage ls --buckets gs://%s", fullBucketName), gcloudArgs).Array()[0] + assert.Equal("awesome", op.Get("metadata.labels.silly").String(), "should have silly label set to awesome") // verify lifecycle rules lifecycle := op.Get("metadata.lifecycle.rule").Array()[0] diff --git a/variables.tf b/variables.tf index 1a8b00b0..cec35b6f 100644 --- a/variables.tf +++ b/variables.tf @@ -30,6 +30,12 @@ variable "names" { type = list(string) } + +variable "silly_label" { + description = "Sample label for bucket." + type = string +} + variable "randomize_suffix" { description = "Adds an identical, but randomized 4-character suffix to all bucket names" type = bool