s3 bucket existence - unexpected behavior
Same issue as #796, looks like a regression (aws-sdk (2.2.34))
require 'aws-sdk'
resource = Aws::S3::Resource.new(region: 'us-east-1')
bucket = resource.bucket('test-issue-s3')
if bucket.exists?
puts "test"
end
/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/aws-sdk-resources-2.2.34/lib/aws-sdk-resources/resource.rb:134:in `rescue in exists?': Aws::S3::Errors::BadRequest
from /.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/aws-sdk-resources-2.2.34/lib/aws-sdk-resources/resource.rb:131:in `exists?'
from test.rb:6:in `<main>'
I am able to replicate the regression, taking a look.
Interestingly, the exact choice of bucket name here matters. The bucket 'test-issue-s3' is in the ap-northeast-1 region. So, for example, this code works:
Aws::S3::Resource.new(region: "ap-northeast-1").bucket('test-issue-s3').exists? #=> true
The issue here comes from the 307 Temporary Redirect we're getting. I get a similar issue if I try to hit a bucket I own in the "eu-central-1" region from a client in "us-east-1".
Looking back at some previous versions, I don't think this is a regression, I don't think this particular case has ever worked. Looking at fix options. I don't think I want to add 400 Bad Request as a successful waiter case, however.
So, the fix here (as Trevor is wrapping up) is to check for the bucket region in headers as well as the body. That will resolve this issue and similar. It's not often encountered because this particular failure modality was not hit by most client methods.
Thanks for the report!
@awood45 Awesome thanks for the quick fix !
I get this error for the region "ap-south-1" - Should I raise a new issue?
S3 client configured for "ap-south-1" but the bucket "dev-embryo-ui" is in "ap-south-1"; Please configure the proper region to avoid multiple unnecessary redirects and signing attempts
/home/travis/.rvm/gems/ruby-2.2.7/gems/aws-sdk-resources-2.10.38/lib/aws-sdk-resources/resource.rb:134:in rescue in exists?': Aws::S3::Errors::BadRequest
from /home/travis/.rvm/gems/ruby-2.2.7/gems/aws-sdk-resources-2.10.38/lib/aws-sdk-resources/resource.rb:131:in exists?'
I've created the bucket in the same region as I ask Travis to deploy. Despite that, I run into this issue.
@ravsom did you ever get solution to above error ? i'm saving same issue
Not really. I changed the workflow to use s3 directly for static web hosting instead of directing it to eb.
On 24 Nov 2017 10:34 am, "raheel0452" [email protected] wrote:
@ravsom https://github.com/ravsom did you ever get solution to above error ? i'm saving same issue
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aws/aws-sdk-ruby/issues/1161#issuecomment-346743647, or mute the thread https://github.com/notifications/unsubscribe-auth/ADwkltSF_ivsEB0UprDE_1uDLcltT_ABks5s5k5KgaJpZM4IKK5f .