Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.aws-sam/
.aws-sam/
.application.json
21 changes: 0 additions & 21 deletions InvokeTextract/src/app.py

This file was deleted.

1 change: 1 addition & 0 deletions invokeTarkovTextract/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.application.json
21 changes: 21 additions & 0 deletions invokeTarkovTextract/lambda_function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from urllib.parse import unquote_plus

import boto3

s3_client = boto3.client('s3')
textract_client = boto3.client('textract')

SNS_TOPIC_ARN = 'arn:aws:sns:eu-west-1:832044451952:AmazonTextract-TarkovTopic' # We need to create this
ROLE_ARN = 'arn:aws:iam::832044451952:role/TextractServiceRole' # This role is managed by AWS

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ROLE_ARN = 'arn:aws:iam::832044451952:role/TextractServiceRole' # This role is managed by AWS
ROLE_ARN = 'arn:aws:iam::832044451952:role/TextractServiceRole' # This role is managed by AWS

Should we be committing ARNs?


def lambda_handler(event, _):
print(f'Event: {event}')
for record in event['Records']:
bucket = record['s3']['bucket']['name']
key = unquote_plus(record['s3']['object']['key'])

print(f'Document detection for {bucket}/{key}')

textract_client.start_document_text_detection(
DocumentLocation={'S3Object': {'Bucket': bucket, 'Name': key}},
NotificationChannel={'RoleArn': ROLE_ARN, 'SNSTopicArn': SNS_TOPIC_ARN})
14 changes: 14 additions & 0 deletions invokeTarkovTextract/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An AWS Serverless Specification template describing your function.
Resources:
invokeTarkovTextract:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: invokeTarkovTextract
Description: ''
Handler: lambda_function.lambda_handler
MemorySize: 128
Role: 'arn:aws:iam::832044451952:role/TarkovLambdaRole'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be committing ARNs?

Suggested change
Role: 'arn:aws:iam::832044451952:role/TarkovLambdaRole'
Role: 'arn:aws:iam::832044451952:role/TarkovLambdaRole'

Runtime: python3.8
Timeout: 3
77 changes: 0 additions & 77 deletions requirements.txt

This file was deleted.