Find region from within an EC2 instance

前端 未结 28 1507
谎友^
谎友^ 2020-12-02 06:24

Is there a way to look up the region of an instance from within the instance?

I\'m looking for something similar to the method of finding the instance id.

28条回答
  •  感动是毒
    2020-12-02 06:53

    If you're able to use the AWS Java SDK, there is now a method that will return the current region name (such as "us-east-1", "eu-west-1"):

    http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/regions/Regions.html#getCurrentRegion()

提交回复
热议问题