【发布时间】:2020-11-07 06:18:24
【问题描述】:
我的 EC2 实例(通过 Elastic Beanstalk)运行我的 ASP.Net Core 3.1 Web 应用程序没有问题。 AWS 凭证包含在与实例一起配置的密钥对中。
我现在想将我的数据保护密钥存储在我为它们创建的 S3 存储桶中,这样我就可以在所有 EC2 实例之间共享这些密钥。但是,当我在 Startup.ConfigureServices 中添加此服务时,我在本地收到运行时错误:
services.AddDefaultAWSOptions(Configuration.GetAWSOptions("AWS"));
services.AddAWSService<IAmazonS3>();
services.AddDataProtection()
.SetApplicationName("Crums")
.PersistKeysToAWSSystemsManager("/CrumsWeb/DataProtection");
如果我注释掉上面的 .PersistKeysToAWSSystemsManager("/CrumsWeb/DataProtection"); 行,我的应用程序在本地运行良好。当我取消注释该行时,会发生错误。所以这与它有关,但我似乎无法弄清楚。
我打算使用 hotchkj 的 PersistKeysToAwsS3,但当 AWS 推出 PersistKeysToAWSSystemsManager 时,它已被弃用。
运行时错误AmazonClientException:未配置 RegionEndpoint 或 ServiceURL 在我的 Program.cs 中的 CreateHostBuilder 上发生:
我已经花了很多时间尝试让 Visual Studio 2019 在本地运行我的应用程序,使用这些网站的建议:
https://aws.amazon.com/blogs/developer/configuring-aws-sdk-with-net-core/
https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-config-netcore.html
ASP NET Core AWS No RegionEndpoint or ServiceURL configured when deployed to Heroku
No RegionEndpoint or ServiceURL configured
https://github.com/secretorange/aws-aspnetcore-environment-startup
https://www.youtube.com/watch?v=C4AyfV3Z3xs&ab_channel=AmazonWebServices
我的 appsettings.Development.json(我也在 appsettings.json 中尝试过)包含:
"AWS": {
"Profile": "default",
"Region": "us-east-1",
"ProfilesLocation": "C:\\Users\\username\\.aws\\credentials"
}
并且凭证文件包含:
[default]
aws_access_key_id = MY_ACCESS_KEY
aws_secret_access_key = MY_SECRET_KEY
region = us-east-1
toolkit_artifact_guid=GUID
【问题讨论】:
标签: amazon-s3 aws-sdk-net