Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/multiple_buckets/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading