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 diff --git a/internal/service/s3/bucket.go b/internal/service/s3/bucket.go index 805db7f5a48..bc53a63aad6 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 configuration: %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) }