Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the EndPoint / Region for the C# .NET SDK : EC2Client?

In the JAVA SDK it's possible to set the endpoint, see here.

But how to do this for .NET SDK ? And what are the names to use?

Because it seems that a default endpoint "US East (Northern Virginia) Region" is always used.

like image 304
Stef Heyenrath Avatar asked Jan 21 '12 00:01

Stef Heyenrath


People also ask

How do I change my default region in AWS?

To choose a default Region In the navigation bar choose your account name and then choose Settings to navigate to the Unified Settings page. Choose Edit next to Localization and default Region. Select your default Region, then choose Save changes.

How do I find my AWS region?

To find your Regions using the consoleOpen the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . From the navigation bar, view the options in the Region selector. Your EC2 resources for this Region are displayed on the EC2 Dashboard in the Resources section.

What is default region name in AWS?

If you signed up for an AWS account on or after May 17, 2017, the default Region when you access a resource from the AWS Management Console is US East (Ohio) (us-east-2); for older accounts, the default Region is either US West (Oregon) (us-west-2) or US East (N. Virginia) (us-east-1).

What is my S3 endpoint URL?

An S3 bucket can be accessed through its URL. The URL format of a bucket is either of two options: http://s3.amazonaws.com/[bucket_name]/ http://[bucket_name].s3.amazonaws.com/


1 Answers

You can also use an endpoint definitions delivered with Amazon SDK:

var ec2Client = new AmazonEC2Client(RegionEndpoint.EUWest1);

Since I believe hard-coding such values as endpoint addresses is not a best practice I use more configurable version (i.e. endpoint configured from web.config/app.config):

var region = RegionEndpoint.GetBySystemName("eu-west-1");
var ec2Client = new AmazonEC2Client(region);
like image 105
Marek Avatar answered Nov 15 '22 21:11

Marek