From 326e42e2d0921f5e83050eb968ddaa30049ebb59 Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Tue, 4 Jul 2017 13:56:57 +0200 Subject: [PATCH] Action and condition blocks of a lifecycle_rule block are both required, use MinItems in schema to enforce --- google/resource_storage_bucket.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/google/resource_storage_bucket.go b/google/resource_storage_bucket.go index 5e0ec39669f..732bfab32cd 100644 --- a/google/resource_storage_bucket.go +++ b/google/resource_storage_bucket.go @@ -88,6 +88,7 @@ func resourceStorageBucket() *schema.Resource { "action": { Type: schema.TypeSet, Required: true, + MinItems: 1, MaxItems: 1, Set: resourceGCSBucketLifecycleRuleActionHash, Elem: &schema.Resource{ @@ -106,6 +107,7 @@ func resourceStorageBucket() *schema.Resource { "condition": { Type: schema.TypeSet, Required: true, + MinItems: 1, MaxItems: 1, Set: resourceGCSBucketLifecycleRuleConditionHash, Elem: &schema.Resource{ @@ -484,10 +486,6 @@ func resourceGCSBucketLifecycleCreateOrUpdate(d *schema.ResourceData, sb *storag if v, ok := lifecycle_rule["condition"]; ok { condition := v.(*schema.Set).List()[0].(map[string]interface{}) - if len(condition) < 1 { - return fmt.Errorf("At least one condition element is required") - } - target_lifecycle_rule.Condition = &storage.BucketLifecycleRuleCondition{} if v, ok := condition["age"]; ok {