Skip to content

Commit

Permalink
Refresh state for deleted s3 bucket correctly
Browse files Browse the repository at this point in the history
If reading an S3 bucket's state, and that bucket has been deleted, don't
fail with a 404 error. Instead, update the state to reflect that the
bucket does not exist. Fixes hashicorp#1574.
  • Loading branch information
Phil Frost committed Apr 17, 2015
1 parent 8f8e93e commit 47e1ec8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion builtin/providers/aws/resource_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error {
Bucket: aws.String(d.Id()),
})
if err != nil {
return err
if awsError, ok := err.(aws.APIError); ok && awsError.StatusCode == 404 {
d.SetId("")
} else {
// some of the AWS SDK's errors can be empty strings, so let's add
// some additional context.
return fmt.Errorf("error reading S3 bucket \"%s\": %#v", d.Id())
}
}

tagSet, err := getTagSetS3(s3conn, d.Id())
Expand Down

0 comments on commit 47e1ec8

Please sign in to comment.