承担角色问题 - 无法使用 EC2 实例元数据服务检索临时凭证

问题描述 投票:0回答:1

在 EC2 实例内的控制台应用程序中使用

AssumeRole
时,它能够使用元数据服务检索临时凭证。但是,当在 Windows 服务中使用相同的代码时,我无法连接到元数据服务。

当 fiddler 打开时,它再次能够连接到元数据服务。请让我知道可能是什么问题。以下是使用内部 Windows 服务时抛出的错误和内部错误。

One or more errors occurred. Amazon.Runtime.AmazonServiceException: Unable to get IAM security credentials from EC2 Instance Metadata Service. at Amazon.Runtime.DefaultInstanceProfileAWSCredentials.FetchCredentials() at Amazon.Runtime.DefaultInstanceProfileAWSCredentials.GetCredentials() at Amazon.Runtime.DefaultInstanceProfileAWSCredentials.GetCredentialsAsync() at Amazon.Runtime.Internal.CredentialsRetriever.d__71.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Amazon.Runtime.Internal.RetryHandler.d__101.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Amazon.Runtime.Internal.RetryHandler.d__101.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.CallbackHandler.d__91.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.CallbackHandler.d__91.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.ErrorCallbackHandler.d__51.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.MetricsHandler

复制步骤-

AmazonSecurityTokenServiceClient client = new AmazonSecurityTokenServiceClient();
var response = client.AssumeRoleAsync(new AssumeRoleRequest
{
  RoleArn = "rolearn",
  RoleSessionName = "sessionname"
});
Amazon.SecurityToken.Model.Credentials credentials = response.Result.Credentials;

AWS .NET SDK 和/或使用的包版本:

  • AWSSDK.SecurityToken
  • AWSSDK..核心

目标 .NET 平台

  • .NET 框架 4.8

操作系统和版本

  • Windows 10
amazon-web-services security metadata temporary
1个回答
0
投票

我已成功将角色分配给 EC2 实例,通过控制台应用程序我的意思是 .Net Framework 命令行控制台应用程序

© www.soinside.com 2019 - 2024. All rights reserved.