【问题标题】:How to change AWS SDK region in code?如何在代码中更改 AWS 开发工具包区域?
【发布时间】:2017-01-04 13:58:08
【问题描述】:

需要定义

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

App.config 中的应用程序设置以指定要使用的区域。

我需要以编程方式更改它

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

如何在代码中指定区域?

【问题讨论】:

    标签: c# .net asp.net-core aws-sdk


    【解决方案1】:

    最佳做法是使用更多可配置版本(即从web.config/app.config 配置的端点)。对于 EC2 客户端,您可以通过以下方式进行:

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

    出于其他原因,您可以从here指定

    资源链接:

    1. How to set the EndPoint / Region for the C# .NET SDK : EC2Client?
    2. How to start an Amazon EC2 instance programmatically in .NET

    【讨论】:

      猜你喜欢
      • 2016-04-26
      • 1970-01-01
      • 2019-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多