0

It is necessary to define

<add key="AWSRegion" value="us-east-1"/>

application setting in App.config to specify region to use.

I need to change that programmatically

var creds = new BasicAWSCredentials(key, token);
using (var routes = AWSClientFactory.CreateAmazonRoute53Client(creds)){}

how to specify the region in code?

dr11
  • 5,166
  • 11
  • 35
  • 77

1 Answers1

5

It is the best practice to use more configurable version (i.e. endpoint configured from web.config/app.config). For EC2 client, you can do it by the following way:

var region = RegionEndpoint.GetBySystemName("ap-northeast-1"); 
var awsEC2Client = new AmazonEC2Client(region);

For others reason, you can specify from here

Resource Link:

  1. How to set the EndPoint / Region for the C# .NET SDK : EC2Client?
  2. How to start an Amazon EC2 instance programmatically in .NET
Community
  • 1
  • 1
SkyWalker
  • 28,384
  • 14
  • 74
  • 132