From 76b62a60736def663e1c40149ae4582a006be100 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Thu, 13 Jan 2022 14:43:56 -0500 Subject: [PATCH 1/3] s3/bucket: Guard against object lock error --- internal/service/s3/bucket.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/service/s3/bucket.go b/internal/service/s3/bucket.go index 805db7f5a48..4d33a1b5611 100644 --- a/internal/service/s3/bucket.go +++ b/internal/service/s3/bucket.go @@ -1304,9 +1304,18 @@ func resourceBucketRead(d *schema.ResourceData, meta interface{}) error { } // Object Lock configuration. - if conf, err := readS3ObjectLockConfiguration(conn, d.Id()); err != nil { + conf, err := readS3ObjectLockConfiguration(conn, d.Id()) + + // Object lock not supported in all partitions (extra guard, also guards in read func) + if err != nil && (meta.(*conns.AWSClient).Partition == endpoints.AwsPartitionID || meta.(*conns.AWSClient).Partition == endpoints.AwsUsGovPartitionID) { return fmt.Errorf("error getting S3 Bucket Object Lock configuration: %s", err) - } else { + } + + if err != nil { + log.Printf("[WARN] Unable to read S3 bucket (%s) object lock configuraton: %s", d.Id(), err) + } + + if err == nil { if err := d.Set("object_lock_configuration", conf); err != nil { return fmt.Errorf("error setting object_lock_configuration: %s", err) } From 27a06f9260261a3ec0aece0b5c338c49bd8545bb Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Thu, 13 Jan 2022 14:46:13 -0500 Subject: [PATCH 2/3] Add changelog --- .changelog/22575.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/22575.txt diff --git a/.changelog/22575.txt b/.changelog/22575.txt new file mode 100644 index 00000000000..54344d7e5e9 --- /dev/null +++ b/.changelog/22575.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_s3_bucket: Add additional protection against `object_lock_configuration` causing errors in partitions (e.g., ISO) where not supported +``` \ No newline at end of file From bf5f3b1321295cf237945eb08a885ac515a4d611 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Thu, 13 Jan 2022 15:26:54 -0500 Subject: [PATCH 3/3] Miss your spelling --- internal/service/s3/bucket.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/s3/bucket.go b/internal/service/s3/bucket.go index 4d33a1b5611..bc53a63aad6 100644 --- a/internal/service/s3/bucket.go +++ b/internal/service/s3/bucket.go @@ -1312,7 +1312,7 @@ func resourceBucketRead(d *schema.ResourceData, meta interface{}) error { } if err != nil { - log.Printf("[WARN] Unable to read S3 bucket (%s) object lock configuraton: %s", d.Id(), err) + log.Printf("[WARN] Unable to read S3 bucket (%s) object lock configuration: %s", d.Id(), err) } if err == nil {