The following code works from a Console application, but does not work when running this same code from a Windows Service. We've made sure the User Account that is running the Serice is permissioned, but unfortunately we still get the error message below.
Are there any options can try for troubleshooting this, or why we might be getting this error from a Service.
var awsOptions = new AWSOptions() {
Region = Amazon.RegionEndpoint.USEast1,
ProfilesLocation = "E:\\AWS\\credentials"
};
var buckets = await awsOptions.CreateServiceClient<Amazon.S3.IAmazonS3> ().ListBucketsAsync(default);
Console.WriteLine(string.Join(Environment.NewLine, buckets.Buckets.Select(x => x.BucketName)));
Error Message...
Amazon.Runtime.AmazonServiceException Unable to get IAM security credentials from EC2 Instance Metadata Service.
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.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.S3.Internal.AmazonS3ExceptionHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext) at Gaige.Job.Testing.ConfigurationTestJob.TestJob() in C:\Users\gmarx\source\repos\institutional-claims\Gaige.Job\Testing\ConfigurationTestJob.cs:line 53 at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)