Reputation: 65
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.
Upvotes: 5
Views: 5333
Reputation: 32212
If you're using the .NET SDK, it's as simple as
var region = Amazon.Util.EC2InstanceMetadata.Region;
It has two main properties, DisplayName
and SystemName
. The former gives you strings such as "EU West (London)"
, while the latter gives "eu-west-2"
.
Upvotes: 6
Reputation: 78842
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.
Upvotes: 0