Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Region detection #1455

Open
stefansedich opened this issue Mar 15, 2017 · 18 comments
Open

Region detection #1455

stefansedich opened this issue Mar 15, 2017 · 18 comments
Labels
feature-request A feature should be added or improved. p3 This is a minor priority issue

Comments

@stefansedich
Copy link

Is there currently a way too detect the current region like is available in the Java SDK for example https://aws.amazon.com/blogs/developer/determining-an-applications-current-region/

At the moment I am having to set the AWS_REGION environment variable manually which I was hoping to avoid.

@awood45 awood45 added feature-request A feature should be added or improved. Version 2 labels Mar 15, 2017
@awood45
Copy link
Member

awood45 commented Mar 15, 2017

We haven't implemented region fetching from the EC2 instance metadata service yet, no. Adding this as a feature request.

@stefansedich
Copy link
Author

Thanks @awood45!

@AlexMorreale
Copy link

+1

@awood45
Copy link
Member

awood45 commented Apr 21, 2017

Adding to feature request backlog.

@awood45 awood45 closed this as completed Apr 21, 2017
awood45 added a commit that referenced this issue Apr 21, 2017
awood45 added a commit that referenced this issue Jun 29, 2017
@mullermp
Copy link
Contributor

Reopening - deprecating usage of Feature Requests backlog markdown file.

@mullermp mullermp reopened this Oct 21, 2019
@mullermp mullermp removed the v2 label Oct 21, 2019
@sivagollapalli
Copy link
Contributor

@mullermp Currently when I pull a single EC2 instance metadata, it has given instance data and it's availability zone information but no region information included in the response. Can we considered availability zone as current region information?

@mullermp
Copy link
Contributor

Hi @sivagollapalli -- If I recall correctly, this was put aside because there were changes coming to the IMDS API and we didn't want to include any potential breakage from before and after that change. I can check back in with the EC2 team after the holidays and see if that's still the case. Last I looked, I believe there is a region field or some way to get the region (using the AZ as you said).

@sivagollapalli
Copy link
Contributor

@mullermp Any update on this?

@mullermp
Copy link
Contributor

Right now there's no good way to get the region

docs: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html

Unfortunately this has been long requested, I will try to make a stink on it somewhere: https://forums.aws.amazon.com/thread.jspa?threadID=77228

The best thing we can do is query for placement/availability-zone and strip off the last letter, though this isn't guaranteed to work.

sivagollapalli added a commit to sivagollapalli/aws-sdk-ruby that referenced this issue Apr 21, 2020
@siva-wal
Copy link

added PR @mullermp

@mullermp
Copy link
Contributor

placement/region has been available for a while now - reminder to myself that I will pick this up as part of #2444

@github-actions
Copy link

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Dec 12, 2021
@mullermp mullermp removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Dec 13, 2021
@makrsmark
Copy link

looks like there's already code to query the metadata service for the region - https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-core/lib/aws-defaults/defaults_mode_config_resolver.rb#L65-L86

Setting AWS_DEFAULTS_MODE=auto does not seem to set the region. Any chance this can be updated?

@alextwoods
Copy link
Contributor

The defaults mode is cross SDK behavior and the application region detection is used to determine only whether to use in-region or cross-region defaults (mostly http timeout defaults) and wasn't intended to be used to set client region.

But that being said - providing region detection as part of client region resolution is still a feature request we are planning on.

@mullermp
Copy link
Contributor

mullermp commented Mar 1, 2023

Doing so in the current major version I think is risky and can cause errors (changes configuration in a minor version). If you agree, I think we should label this as major version only.

@makrsmark
Copy link

The precedence is already environment then profile. I don't see how having the metadata service be the lowest priority (and match how credentials are resolved) is a breaking change. especially since it's how it works in both v1 and v2

@alextwoods
Copy link
Contributor

Since region is a required configuration option and precedence is already environment, then profile, I do agree, I think the risk is lower. I am slightly concerned by an increase in client creation time (caused by the extra network call) + an extra network call. But this would only happen in the case where client creation would currently fail and raise an error.

@mullermp
Copy link
Contributor

mullermp commented Mar 2, 2023

Ah yeah that makes sense, if it's last. We have very aggressive timeouts for "testing" if we are on an ec2 host. I suppose we only have to do that once in both the region config chain (new concept) and credential provider chain if we use some client class variable or something like that.

@bhavya2109sharma bhavya2109sharma added the p3 This is a minor priority issue label Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p3 This is a minor priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants