From 5e3f8c597dc87b91ce724444eaffbb268d60cddf Mon Sep 17 00:00:00 2001 From: Nathan McKinley Date: Thu, 24 Oct 2019 16:30:06 -0700 Subject: [PATCH 1/3] Don't lock policy if it is already locked. --- third_party/terraform/resources/resource_storage_bucket.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/third_party/terraform/resources/resource_storage_bucket.go b/third_party/terraform/resources/resource_storage_bucket.go index b1fbcb75bc66..817a35db58c8 100644 --- a/third_party/terraform/resources/resource_storage_bucket.go +++ b/third_party/terraform/resources/resource_storage_bucket.go @@ -392,7 +392,9 @@ func resourceStorageBucketCreate(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Created bucket %v at location %v\n\n", res.Name, res.SelfLink) d.SetId(res.Id) - if v, ok := d.GetOk("retention_policy"); ok { + // If the retention policy is not already locked, check if it + // needs to be locked. + if v, ok := d.GetOk("retention_policy"); ok && !res.RetentionPolicy.IsLocked { retention_policies := v.([]interface{}) sb.RetentionPolicy = &storage.BucketRetentionPolicy{} From 6a198a853c2c0200b09dc774bc22c6460dbd28ff Mon Sep 17 00:00:00 2001 From: Nathan McKinley Date: Fri, 25 Oct 2019 12:02:15 -0700 Subject: [PATCH 2/3] Check in update as well as in create. --- third_party/terraform/resources/resource_storage_bucket.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/terraform/resources/resource_storage_bucket.go b/third_party/terraform/resources/resource_storage_bucket.go index 817a35db58c8..683cd690a246 100644 --- a/third_party/terraform/resources/resource_storage_bucket.go +++ b/third_party/terraform/resources/resource_storage_bucket.go @@ -516,7 +516,7 @@ func resourceStorageBucketUpdate(d *schema.ResourceData, meta interface{}) error retentionPolicy := retention_policies[0].(map[string]interface{}) - if locked, ok := retentionPolicy["is_locked"]; ok && locked.(bool) { + if locked, ok := retentionPolicy["is_locked"]; ok && locked.(bool) && d.HasChange("retention_policy.0.is_locked") { err = lockRetentionPolicy(config.clientStorage.Buckets, d.Get("name").(string), res.Metageneration) if err != nil { return err From e77c038610be6ee5f1227503dbd360b10dbe0972 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Fri, 25 Oct 2019 20:03:20 +0000 Subject: [PATCH 3/3] Update tracked submodules -> HEAD on Fri Oct 25 20:03:20 UTC 2019 Tracked submodules are build/terraform-beta build/terraform-mapper build/terraform build/ansible build/inspec. --- build/terraform | 2 +- build/terraform-beta | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/terraform b/build/terraform index 264f981107ba..b28342443e78 160000 --- a/build/terraform +++ b/build/terraform @@ -1 +1 @@ -Subproject commit 264f981107bae8e34ed44e04cf380f251029103c +Subproject commit b28342443e78709c362d893bda09c28e45938116 diff --git a/build/terraform-beta b/build/terraform-beta index b40632cd5c53..379f53be9fb5 160000 --- a/build/terraform-beta +++ b/build/terraform-beta @@ -1 +1 @@ -Subproject commit b40632cd5c53fc2c4ac86cf9ae70c2b48a47c48f +Subproject commit 379f53be9fb5a0c68cac127910147d6215a40ca5