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

Detect AWS Region using the metadata service #7697

Closed
Tieske opened this issue Aug 10, 2021 · 7 comments
Closed

Detect AWS Region using the metadata service #7697

Tieske opened this issue Aug 10, 2021 · 7 comments

Comments

@Tieske
Copy link
Member

Tieske commented Aug 10, 2021

continuation of Kong/kong-plugin-aws-lambda#56

@bungle bungle changed the title Detect Region using the metadata service Detect AWS Region using the metadata service Aug 10, 2021
@Tieske
Copy link
Member Author

Tieske commented Aug 10, 2021

In addition to the info in the original PR, there's also some pointers here; in the Java sdk; https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/region-selection.html#automatically-determine-the-aws-region-from-the-environment

@Tieske
Copy link
Member Author

Tieske commented Aug 10, 2021

Try logic (updated from the old issue):

  • read AWS_REGION environment variable (std across AWS cli apparently)
  • read AWS_DEFAULT_REGION environment variable (std across AWS cli apparently)
  • scan for ECS_CONTAINERMETADATA_URI_V4 or ECS_CONTAINERMETADATA_URI environment variables
  • if found request and get AvailabilityZone --> seems to be ECS (we're skipping the V2 on ECS, which seems valid since its outdated)
  • else try IMDSv2 (risks blocking) --> assumes it to be EC2, use short timeout, eg. 5 seconds
  • requests should be within a lock to prevent many simultaneously
  • the actual requests should be made a run-time, not during start up, because during startup we do not even know whether we're running on AWS infra or even if we need the region info, and then we'd possibly incur the penalty of the blocking requests until a timeout

Option would be to implement the first two above first, and the remainder later.

@Tieske
Copy link
Member Author

Tieske commented Aug 16, 2021

@bungle here's my implementation in the AWS SDK: Kong/lua-resty-aws#9

@gszr
Copy link
Member

gszr commented Mar 21, 2023

@bungle @Tieske What specific bits aren't covered by #7765?

@Tieske
Copy link
Member Author

Tieske commented Mar 22, 2023

the env var is only one options whilst there are many more. Any way AWS has no supported way of detecting it.

The AWS Lambda plugin should be rewritten on top of the aws-sdk, that would solve the issue.

@Tieske Tieske closed this as completed Mar 22, 2023
@gszr
Copy link
Member

gszr commented Mar 22, 2023

The AWS Lambda plugin should be rewritten on top of the aws-sdk, that would solve the issue.

@Tieske Are we keeping track of this task somewhere? Thanks for explaining!

@Tieske
Copy link
Member Author

Tieske commented Mar 22, 2023

internally FTI-4296

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants