Skip to content

Commit

Permalink
Merge pull request #3338 from terraform-providers/b-aws_s3_bucket-tim…
Browse files Browse the repository at this point in the history
…eout-crash

resource/aws_s3_bucket: Prevent crashes on location and replication read retry timeouts
  • Loading branch information
bflad authored Feb 13, 2018
2 parents 7302b61 + 4c22429 commit 33d309d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions aws/resource_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -970,12 +970,12 @@ func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error {
Bucket: aws.String(d.Id()),
})
})
replication := replicationResponse.(*s3.GetBucketReplicationOutput)
if err != nil {
if awsError, ok := err.(awserr.RequestFailure); ok && awsError.StatusCode() != 404 {
return err
}
}
replication := replicationResponse.(*s3.GetBucketReplicationOutput)

log.Printf("[DEBUG] S3 Bucket: %s, read replication configuration: %v", d.Id(), replication)
if r := replication.ReplicationConfiguration; r != nil {
Expand Down Expand Up @@ -1019,10 +1019,10 @@ func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error {
},
)
})
location := locationResponse.(*s3.GetBucketLocationOutput)
if err != nil {
return err
}
location := locationResponse.(*s3.GetBucketLocationOutput)
var region string
if location.LocationConstraint != nil {
region = *location.LocationConstraint
Expand Down Expand Up @@ -1373,10 +1373,10 @@ func websiteEndpoint(s3conn *s3.S3, d *schema.ResourceData) (*S3Website, error)
},
)
})
location := locationResponse.(*s3.GetBucketLocationOutput)
if err != nil {
return nil, err
}
location := locationResponse.(*s3.GetBucketLocationOutput)
var region string
if location.LocationConstraint != nil {
region = *location.LocationConstraint
Expand Down

0 comments on commit 33d309d

Please sign in to comment.