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.

질문됨 2년 전241회 조회
2개 답변
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
답변함 2년 전
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

답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠