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.
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.
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);
Regions and Endpoints can be found here.
And example how to connect to EU:
AmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client("key", "secret",
new AmazonEC2Config
{
ServiceURL = "http://ec2.eu-west-1.amazonaws.com"
}
);
You can also define the aws region in your configuration file using the region code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="AWSProfileName" value="default"/>
<add key="AWSRegion" value="eu-west-1"/>
</appSettings>
</configuration>
Then you can simply instanciate your ec2Client without any region:
var ec2Client = new AmazonEC2Client();
Console.WriteLine(ec2Client.Config.RegionEndpoint.DisplayName);
Output:
EU West (Ireland)
Regions and endpoint are defined here: http://docs.aws.amazon.com/general/latest/gr/rande.html