mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
more tightly scope s3 bucket object error
This commit is contained in:
parent
285b4061db
commit
bfaea76b86
@ -8,6 +8,7 @@ import (
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
)
|
||||
|
||||
@ -89,11 +90,14 @@ func resourceAwsS3BucketObjectRead(d *schema.ResourceData, meta interface{}) err
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
// if there is an error reading the object we assume it's not there.
|
||||
// If S3 returns a 404 Request Failure, mark the object as destroyed
|
||||
if awsErr, ok := err.(awserr.RequestFailure); ok && awsErr.StatusCode() == 404 {
|
||||
d.SetId("")
|
||||
log.Printf("Error Reading Object (%s): %s", key, err)
|
||||
log.Printf("[WARN] Error Reading Object (%s), object not found (HTTP status 404)", key)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Reading S3 Bucket Object meta: %s", resp)
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user