GithubHelp home page GithubHelp logo

Bucket Region about goamz HOT 14 CLOSED

adroll avatar adroll commented on June 27, 2024
Bucket Region

from goamz.

Comments (14)

alimoeeny avatar alimoeeny commented on June 27, 2024

How does boto do it? is there a look up api or something?

from goamz.

ET-CS avatar ET-CS commented on June 27, 2024

In python I use the following code (without region):

from boto.s3.connection import S3Connection
s3conn = S3Connection(key, secret)
bucket = s3conn.get_bucket(bucketname)

I am not finding where I read that when region is missing, it's called 'universal' region, but I'm looking for it now.
This is the api : http://boto.readthedocs.org/en/latest/ref/s3.html#module-boto.s3.connection

from goamz.

ET-CS avatar ET-CS commented on June 27, 2024

Maybe this will help
http://stackoverflow.com/questions/23239877/how-does-boto-choose-aws-region-to-create-buckets

from goamz.

ET-CS avatar ET-CS commented on June 27, 2024

Maybe boto is checking aws GetBucketLocation api, or it's looping through all regions to find where the bucket is. I don't really know. but I know it's working. I can't find a way in goamz to connect to bucket when the region is unknown.

from goamz.

ET-CS avatar ET-CS commented on June 27, 2024

And thank you for your quick answer!

from goamz.

alimoeeny avatar alimoeeny commented on June 27, 2024

I really don't know if there already is a way to to it with goamz or not, if you asked me before this, I would have said goamz does not care, you don't need to know the region, but I have not read that part of the code in ages, maybe people who actually done so should answer and I should shut my mouth :)

from goamz.

ET-CS avatar ET-CS commented on June 27, 2024

I am using the following code:.

conn := s3.New(auth, aws.USWest2) // Here is the part which region is needed
bucket := conn.Bucket("bucketName")
file, err := bucket.Get("somefile")

The s3.New() inforce me to supply region. maybe I am doing it wrong. I've tried to look in the source to find another way to create s3 object without region but found nothing.
https://github.com/crowdmob/goamz/blob/master/s3/s3.go#L91
https://godoc.org/launchpad.net/goamz/s3#New

thanks again.

from goamz.

alimoeeny avatar alimoeeny commented on June 27, 2024

Why not provide it? you can get your region with aws.InstanceRegion()

from goamz.

ET-CS avatar ET-CS commented on June 27, 2024

Thank you.
I've tried. aws.InstanceRegion() always returning "unknown".
looking at the source, the url http://169.254.169.254/latest/meta-data/placement/availability-zone seems to be broken.
I've followed again the boto source and haven't found anything regards region in the process of the the functions I call. It's like region is not needed for boto (or I missed, and boto does finds the region by himself). I don't know really how boto do that.

from goamz.

alimoeeny avatar alimoeeny commented on June 27, 2024

You mean on actual EC2 instances it returns "unknown" ?! really? what region are you trying it on?
If you curl that url on your machine what would you get back?

from goamz.

ET-CS avatar ET-CS commented on June 27, 2024

Thank you for your response. My region is USWest2.
I am using the following code:

    // Get Auth object
    auth, err := aws.GetAuth(key, secret, "", time.Time{})
    if err != nil { return err }

    // Get S3 Bucket Connection
    fmt.Print(aws.InstanceRegion())                    // aws.InstanceRegion() == always to 'unknown'
    conn := s3.New(auth, aws.USWest2)
    bucket := conn.Bucket(bucketName)

If I curl http://169.254.169.254/latest/meta-data/placement/availability-zone it returns
curl: (7) couldn't connect to host

from goamz.

alimoeeny avatar alimoeeny commented on June 27, 2024

if you curl that url on your EC2 instance and you get the could not connect error, the only thing that comes to mind is you have some firewall (iptables?) that prevents that, what kind of machine is this? what ami are you using? to make sure I just tried it and I get:

$ curl http://169.254.169.254/latest/meta-data/placement/availability-zone
us-east-1e$

from goamz.

ET-CS avatar ET-CS commented on June 27, 2024

Sorry, I didn't explained well. I am not working on EC2 instance. I develop a software on a local machine - a program that fetchs data from S3 bucket for several key/secret combinations. Currently it's working alright with the above code, but as you noticed - I've explicitly set the region in the s3.New() function to aws.USWest2.
Now, as others will use this application too, and I don't know what region there are in, I am trying to find a way to find the region automatically or better, not supply any (as in boto).
I guess that aws.InstanceRegion() is working on EC2 instance only?

from goamz.

alimoeeny avatar alimoeeny commented on June 27, 2024

got you, that is why you get unknown region, I don't know of any solution, but I am sure there is one,

from goamz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.