Error while calling API DetectDocumentTextAsync - One or more errors occurred. (Unable to get IAM security credentials from EC2 Instance Metadata Service

0

Hi I am sharing below error, dont know why this error showing.2-3 days before this code was working and now i am getting this error, i have not changed any setting. Please help to understand this error Code showing error

var result = new DetectDocumentTextResponse(); var s3Object = new S3Object { Bucket = bucketName, Name = key }; var request = new DetectDocumentTextRequest(); request.Document = new Document { S3Object = s3Object }; // line returning error return await this.textract.DetectDocumentTextAsync(request);

System.AggregateException HResult=0x80131500 Message=One or more errors occurred. (Unable to get IAM security credentials from EC2 Instance Metadata Service.) Source=System.Private.CoreLib StackTrace: at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Dotnet_Core.ArgHandlers.DetectTextS3Handler.Handle(String bucketName, String s3File) in D:\amazon-textract-code-samples-master\amazon-textract-code-samples-master\src-csharp\ArgHandlers\DetectTextS3Handler.cs:line 14 at Dotnet_Core.Program.Main(String[] args) in D:\amazon-textract-code-samples-master\amazon-textract-code-samples-master\src-csharp\Program.cs:line 55

This exception was originally thrown at this call stack: [External Code] Dotnet_Core.Services.TextractTextDetectionService.DetectTextS3(string, string) in TextractTextDetectionService.cs

Inner Exception 1: AmazonServiceException: Unable to get IAM security credentials from EC2 Instance Metadata Service.

gefragt vor 2 Jahren241 Aufrufe
2 Antworten
0

Hi,

To better understand your issue, could you please

  1. How did your code get the necessary permission? if you use AWS SDK could you please provide the code block.

  2. As it was working before, could you please verify your EC2 instance is healthy and has correct IAM attached, if possible, could you please try to relaunch a new instance and deploy the code to see if it works on new instance.

Thanks

AWS
Jady
beantwortet vor 2 Jahren
0

Dear Jady, Thankyou for your response, below is peace of code i am using I am not using ec2 instance, even not created, using dotnet core application on laptop and accessing Textract sdk var builder = new ConfigurationBuilder() .SetBasePath(Environment.CurrentDirectory) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddEnvironmentVariables() .Build(); var awsOptions = builder.GetAWSOptions(); Console.WriteLine(awsOptions.Profile + ":" + awsOptions.ProfilesLocation + ": " + awsOptions.Region.DisplayName);

IAmazonTextract textract =awsOptions.CreateServiceClient<IAmazonTextract>(); var request = new StartDocumentTextDetectionRequest(); request.DocumentLocation = new DocumentLocation { S3Object = new S3Object { Bucket = "testautomatelab",
Name = "test-files/employmentapp.png" } }; var response = textract.StartDocumentTextDetectionAsync(request); }

Receiving response Id = 263, Status = Faulted, Method = "{null}", Result = "{Not yet computed}"

Response Inner exception One or more errors occurred. (Unable to get IAM security credentials from EC2 Instance Metadata Service

beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen