Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve support for third party S3 #23278

Merged
merged 4 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/23278.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_s3_bucket: Add error handling for `NotImplemented` and `XNotImplemented` errors when reading `acceleration_status`, `policy`, `request_payer`, or `website` into terraform state.
```
8 changes: 4 additions & 4 deletions internal/service/s3/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ func resourceBucketRead(d *schema.ResourceData, meta interface{}) error {
return nil
}

if err != nil && !tfawserr.ErrCodeEquals(err, ErrCodeNoSuchBucketPolicy) {
if err != nil && !tfawserr.ErrCodeEquals(err, ErrCodeNoSuchBucketPolicy, ErrCodeNotImplemented) {
return fmt.Errorf("error getting S3 bucket (%s) policy: %w", d.Id(), err)
}

Expand Down Expand Up @@ -909,7 +909,7 @@ func resourceBucketRead(d *schema.ResourceData, meta interface{}) error {
return nil
}

if err != nil && !tfawserr.ErrCodeEquals(err, ErrCodeNotImplemented, ErrCodeNoSuchWebsiteConfiguration) {
if err != nil && !tfawserr.ErrCodeEquals(err, ErrCodeNotImplemented, ErrCodeNoSuchWebsiteConfiguration, ErrCodeXNotImplemented) {
return fmt.Errorf("error getting S3 Bucket website configuration: %w", err)
}

Expand Down Expand Up @@ -970,7 +970,7 @@ func resourceBucketRead(d *schema.ResourceData, meta interface{}) error {
}

// Amazon S3 Transfer Acceleration might not be supported in the region
if err != nil && !tfawserr.ErrCodeEquals(err, ErrCodeMethodNotAllowed, ErrCodeUnsupportedArgument) {
if err != nil && !tfawserr.ErrCodeEquals(err, ErrCodeMethodNotAllowed, ErrCodeUnsupportedArgument, ErrCodeNotImplemented) {
return fmt.Errorf("error getting S3 Bucket acceleration configuration: %w", err)
}

Expand All @@ -995,7 +995,7 @@ func resourceBucketRead(d *schema.ResourceData, meta interface{}) error {
return nil
}

if err != nil {
if err != nil && !tfawserr.ErrCodeEquals(err, ErrCodeNotImplemented) {
return fmt.Errorf("error getting S3 Bucket request payment: %s", err)
}

Expand Down
5 changes: 5 additions & 0 deletions internal/service/s3/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ const (
ErrCodeReplicationConfigurationNotFound = "ReplicationConfigurationNotFoundError"
ErrCodeServerSideEncryptionConfigurationNotFound = "ServerSideEncryptionConfigurationNotFoundError"
ErrCodeUnsupportedArgument = "UnsupportedArgument"

// ErrCodeXNotImplemented is returned from Third Party S3 implementations
// and so far has been noticed with calls to GetBucketWebsite.
// Reference: https://github.com/hashicorp/terraform-provider-aws/issues/14645
ErrCodeXNotImplemented = "XNotImplemented"
)