Skip to content

Commit

Permalink
Merge pull request #23278 from wilfriedroset/third-party-s3
Browse files Browse the repository at this point in the history
Improve support for third party S3
  • Loading branch information
anGie44 authored Feb 18, 2022
2 parents a1bccdb + 22d26fb commit d4b6c38
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .changelog/23278.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/aws_s3_bucket: Add error handling for `NotImplemented` errors when reading `acceleration_status`, `policy`, or `request_payer` into terraform state.
```

```release-note:enhancement
resource/aws_s3_bucket: Add error handling for `MethodNotAllowed` and `XNotImplemented` errors when reading `website` into terraform state.
```
13 changes: 9 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,12 @@ func resourceBucketRead(d *schema.ResourceData, meta interface{}) error {
return nil
}

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

Expand Down Expand Up @@ -970,7 +975,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 +1000,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"
)

0 comments on commit d4b6c38

Please sign in to comment.