Skip to content

Instantly share code, notes, and snippets.

View SumindaD's full-sized avatar

Suminda Niroshan SumindaD

  • 1BillionTech
  • Colombo, Sri Lanka
View GitHub Profile
functions:
pdfgetjobresult:
handler: pdf_extract_result.handle
layers:
- { Ref: Boto3LayerLambdaLayer }
events:
- sns:
topicName: ${self:custom.snsTopicName}
displayName: Pdf Extraction Done SNS
pdfextractstart:
resources:
Resources:
snsAccessRole:
Type: AWS::IAM::Role
Properties:
RoleName: ${self:custom.snsFullAccessRoleName}
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonSNSFullAccess
AssumeRolePolicyDocument:
Statement:
service: textract-ocr-service
custom:
currentStage: ${opt:stage, self:provider.stage}
s3BucketName: textractbucket-#{AWS::AccountId}-${self:custom.currentStage}
snsTopicName: pdfExtractionDone-#{AWS::AccountId}-${self:custom.currentStage}
snsFullAccessRoleName: AwsSnsFullAccessRole-#{AWS::AccountId}-${self:custom.currentStage}
lambdaRunTime: python3.7
provider:
import json
import urllib.parse
import boto3
import os
def handle(event, context):
print("Triggered getTextFromS3PDF event: " + json.dumps(event, indent=2))
# Get the object from the event and show its content type
bucket = event['Records'][0]['s3']['bucket']['name']
import json
import boto3
import os
def getJobResults(jobId):
pages = []
textract = boto3.client('textract')
response = textract.get_document_text_detection(JobId=jobId)
import boto3
import json
from boto3.dynamodb.conditions import Key, Attr
def lambda_handler(event, context):
eventBody = json.loads(json.dumps(event))['body']
searchString = json.loads(eventBody)['Search']
import json
import boto3
import os
dynamodb = boto3.client('dynamodb')
def handle(event, context):
connectionId = event['requestContext']['connectionId']
# Insert the connectionId of the connected device to the database
import json
import boto3
import os
dynamodb = boto3.client('dynamodb')
def handle(event, context):
message = json.loads(event['body'])['message']
import json
import boto3
import os
dynamodb = boto3.client('dynamodb')
def handle(event, context):
connectionId = event['requestContext']['connectionId']
# Delete connectionId from the database
service: awswebsocketchat
frameworkVersion: "1.48.2"
custom:
currentStage: ${opt:stage, self:provider.stage}
lambdaRunTime: python3.7
socketConnectionsTableName: socketConnections-#{AWS::AccountId}-${self:custom.currentStage}
provider:
name: aws