Textract Error When PDF Is Uploaded to Folder

0

Hi,

I currently have a Lambda that is triggered upon uploading a PDF document to an S3 bucket. Once called, the Lambda calls the start_document_text_detection method to extract the document text. The job gets published to an SNS topic and another Lambda gets triggered on completion to get_document_text_detection method to retrieve the results and upload it into said bucket.

If I upload a document to the root of the S3 bucket, everything works great. My issue is that when I create a folder within the S3 bucket and upload a PDF there, the trigger fires but I am getting the following error :

[ERROR] InvalidParameterException: An error occurred (InvalidParameterException) when calling the StartDocumentTextDetection operation: Request has invalid parameters
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 33, in lambda_handler
    raise e
  File "/var/task/lambda_function.py", line 26, in lambda_handler
    'SNSTopicArn': os.environ['sns_arn']
  File "/opt/python/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/opt/python/botocore/client.py", line 661, in _make_api_call
    raise error_class(parsed_response, operation_name)

SNSTopicARN being part of the NotificationChannel argument to the start_document_text_detection call. The RoleARN also has FullSNSAccess policy and the JobTag is the document name if that helps. I checked the limits of Textract and everything is within bounds. I also tried adjusting the prefix in the Events property of the S3 bucket to match the folder, with no luck.

Any advice would be appreciated.

已提问 4 年前671 查看次数
1 回答
0
已接受的回答

Hi, Thank you for reaching out to us!

As per the error log shared in the post, it looks like the failure is triggered because the SNSTopicArn is probably not be getting set correctly. Could you check if the environment variable 'sns_arn' contains the intended ARN?

Regards,
Srikanth.

已回答 4 年前
profile picture
专家
已审核 1 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则