mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Refresh state for deleted s3 bucket correctly
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 #1574.
This commit is contained in:
parent
8f8e93e657
commit
47e1ec85f1
@ -85,7 +85,13 @@ func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error {
|
|||||||
Bucket: aws.String(d.Id()),
|
Bucket: aws.String(d.Id()),
|
||||||
})
|
})
|
||||||
if err != nil {
|
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())
|
tagSet, err := getTagSetS3(s3conn, d.Id())
|
||||||
|
Loading…
Reference in New Issue
Block a user