无法从EC2实例元数据服务获取IAM安全证书-.netcore AWS开发工具包

时间:2020-09-24 19:58:32

标签: c# amazon-web-services .net-core aws-sdk amazon-glacier

我有一个命令行应用程序,用于将某些文件上传到AWS。我使用了认证示例

        var options = new CredentialProfileOptions
        {
            AccessKey = "bleh",
            SecretKey = "bleh"
        };
        var profile = new CredentialProfile("basic_profile", options);
        profile.Region = RegionEndpoint.USEast2;
        var netSDKFile = new NetSDKCredentialsFile();
        netSDKFile.RegisterProfile(profile);
        var manager = new ArchiveTransferManager(Amazon.RegionEndpoint.USEast2);

是时候上传了

archiveToUpload = System.IO.Path.Combine(record.FolderName, record.FileName);
string archiveId = manager.UploadAsync(vaultName, "upload archivetest",archiveToUpload).Result.ArchiveId;

我收到“无法从EC2实例元数据服务获取IAM安全凭证”异常。这正在我的开发桌面上运行。 IAM用户还可以完全访问S3和冰川进行测试。我的开发环境是否缺少某些配置?我还安装了适用于VS2019的AWS开发工具包,并验证basic_profile可以探索S3。

谢谢!

1 个答案:

答案 0 :(得分:0)

Documentation看来,您的角色需要glacier:UploadArchive

enter image description here

确保您的角色具有此权限。或尝试将其作为管理员角色运行,以确保没有其他问题。