.net core 使用AWS本地配置文件进行开发的AWS.NET核心工作程序服务正在尝试从实例配置文件访问IAM凭据?

.net core 使用AWS本地配置文件进行开发的AWS.NET核心工作程序服务正在尝试从实例配置文件访问IAM凭据?,.net-core,amazon-iam,worker,aws-sdk-net,.net Core,Amazon Iam,Worker,Aws Sdk Net,我有一个.NET核心工作者服务,它使用AWS SQS从队列中读取消息。对于本地开发,我使用默认配置文件,其中存储了访问/密钥。My appSettings.json的设置如下: { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" }, "Ta

我有一个.NET核心工作者服务,它使用AWS SQS从队列中读取消息。对于本地开发,我使用默认配置文件,其中存储了访问/密钥。My appSettings.json的设置如下:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    },
    "TargetCloudWatchGroup": "/aws/insite/workers"
  },
  "App": {
    "TaskProcessDelay": 10000,
    "Environment": "NA",
    "WorkerType": "INCOMING"
  },
  "AWS": {
    "Region": "ap-southeast-2",
    "Profile": "default",
    "ProfilesLocation": "C:\\Users\\JMatson\\.aws\\credentials",
    "AwsQueueLongPollTimeSeconds": 5,
    "QueueUrl": "https://sqs.ap-southeast-2.amazonaws.com/712510509017/insite-incoming-dev"
  }
}
我正在使用DI设置服务:

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureServices((hostContext, services) =>
        {
            //var options = hostContext.Configuration.GetAWSOptions();
            services.AddDefaultAWSOptions(hostContext.Configuration.GetAWSOptions());
            services.AddHostedService<Worker>();
            services.AddSingleton<ILogger, Logger>(); // Using my own basic wrapper around NLog for the moment, pumped to CloudWatch.
            services.AddAWSService<IAmazonSQS>();
        });
那么为什么它会失败呢?如果我查看即时窗口,我可以看到它正在接收我的设置:

?hostContext.Configuration.GetAWSOptions().Profile
"default"
?hostContext.Configuration.GetAWSOptions().ProfilesLocation
"C:\\Users\\JMatson\\.aws\\credentials"
?hostContext.Configuration.GetAWSOptions().Profile
"default"
?hostContext.Configuration.GetAWSOptions().ProfilesLocation
"C:\\Users\\JMatson\\.aws\\credentials"