Assume Role issue - when using Assume Role in Console application inside EC2 instance it is able to retrieve temporary credentials using metadata Service.

0

Assume Role issue - when using Assume Role in Console application inside EC2 instance it is able to retrieve temporary credentials using metadata Service. but not able to connect to metadata service when same code used inside windows Service , it again was able to connect to metadata service when fiddler was open. Please let me know what might be the issue . Below are the error and inner errors which is thrown when using inside windows service.

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

Expected Behavior My use case is retrieving AWS Temporary Credentials using Metadata service inside EC2 instance . which is also the expected behaviour.

Current Behavior Not able to retrieve Temporary Credentials when code is run inside windows service , but works completely fine when run in a Console Application . or able to run inside windows service when fiddler is open and running .

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

Possible Solution No response

Additional Information/Context No response

AWS .NET SDK and/or Package version used AWSSDK.SecurityToken AWSSDK..Core

Targeted .NET Platform .NET Framework 4.8

Operating System and version Windows 10

asked a year ago326 views
2 Answers
0

The error Amazon.Runtime.AmazonServiceException: Unable to get IAM security credentials from EC2 Instance Metadata Service. at Amazon.Runtime.DefaultInstanceProfileAWSCredentials.FetchCredentials() is likely not able to reach or find the instance profile credentials. The call will then cascade through other options described in https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html and I suspect timing out.

It would be helpful to understand the call you are making that is generating this error. Can you provide that? Sanitised with any identifying info...

profile picture
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions