Is there a way to determine the current AWS region in .Net?
I've been able to find a way to do this in java https://aws.amazon.com/blogs/developer/determining-an-applications-current-region/ but cannot find the equivalent in .Net.
Is there a way to determine the current AWS region in .Net?
I've been able to find a way to do this in java https://aws.amazon.com/blogs/developer/determining-an-applications-current-region/ but cannot find the equivalent in .Net.
This information is available on an EC2 instance from the EC2 Metadata Service. Actually, only the Availability Zone is available but you can infer the region from the AZ.
It looks like this is available in the .Net SDK via Amazon.EC2.Util and EC2Metadata.
If you're using the .NET SDK, it's as simple as
It has two main properties,
DisplayName
andSystemName
. The former gives you strings such as"EU West (London)"
, while the latter gives"eu-west-2"
.