k1LoW / awspec

RSpec tests for your AWS resources.
MIT License
1.17k stars 192 forks source link

Add support for S3 bucket location #529

Closed soruma closed 3 years ago

soruma commented 3 years ago

Fix #524.

Add have_location to see where S3 is located.

describe s3_bucket('my-bucket') do
  it { should have_location('us-east-1') }
end
k1LoW commented 3 years ago

Hi @soruma! Thank you for your commit!! Could you update doc or merge master for fixing test fail?

k1LoW commented 3 years ago

Oops, I see that the aws-sdk has been updated again. I'll take care of this one! Thanks for your nice commit!

k1LoW commented 3 years ago

Released as v1.23.0.

anjo-swe commented 3 years ago

@soruma @k1LoW tried 1.23 locally and it's having issues with us-east-1

Maybe need to change

      def find_bucket_location(id)
        bucket_location = s3_client.get_bucket_location(bucket: id)
        bucket_location.location_constraint

to

      def find_bucket_location(id)
        bucket_location = s3_client.get_bucket_location(bucket: id)
        bucket_location.location_constraint.nil? || bucket_location.location_constraint.empty? ? 'us-east-1' : bucket_location.location_constraint

Related to my comment in the issue

Buckets in Region us-east-1 have a LocationConstraint of null. Maybe handle null and return us-east-1 in that case

soruma commented 3 years ago

Hi @k1LoW

Oops, I see that the aws-sdk has been updated again.

I found out why it didn't happen locally. Thank you.

(Reproduced when the latest aws-sdk is installed.)

tried 1.23 locally and it's having issues with us-east-1

I've only tested with buckets located in ap-northeast-1. I didn't know such a specification of AWS. I'll fix it.