Merge pull request #9031 from kjmkznr/b-aws-s3-lifecycle
provider/aws: Fix failed remove S3 lifecycle_rule
This commit is contained in:
commit
979af97b52
|
@ -1241,6 +1241,23 @@ func resourceAwsS3BucketLifecycleUpdate(s3conn *s3.S3, d *schema.ResourceData) e
|
||||||
|
|
||||||
lifecycleRules := d.Get("lifecycle_rule").([]interface{})
|
lifecycleRules := d.Get("lifecycle_rule").([]interface{})
|
||||||
|
|
||||||
|
if len(lifecycleRules) == 0 {
|
||||||
|
i := &s3.DeleteBucketLifecycleInput{
|
||||||
|
Bucket: aws.String(bucket),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
|
||||||
|
if _, err := s3conn.DeleteBucketLifecycle(i); err != nil {
|
||||||
|
return resource.NonRetryableError(err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error putting S3 lifecycle: %s", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
rules := make([]*s3.LifecycleRule, 0, len(lifecycleRules))
|
rules := make([]*s3.LifecycleRule, 0, len(lifecycleRules))
|
||||||
|
|
||||||
for i, lifecycleRule := range lifecycleRules {
|
for i, lifecycleRule := range lifecycleRules {
|
||||||
|
|
|
@ -566,6 +566,12 @@ func TestAccAWSS3Bucket_Lifecycle(t *testing.T) {
|
||||||
"aws_s3_bucket.bucket", "lifecycle_rule.1.noncurrent_version_expiration.80908210.days", "365"),
|
"aws_s3_bucket.bucket", "lifecycle_rule.1.noncurrent_version_expiration.80908210.days", "365"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccAWSS3BucketConfig(rInt),
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
|
||||||
|
),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue