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
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="google-signin-client_id" content="<CLIENT ID>">
<title>Google Auth To AWS</title>
</head>
<body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.487.0.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<title>MSN AWS App</title>
</head>
<body>
<script src="./script/jquery.min.js"></script>
<script src="./script/aws-sdk-2.487.0.min.js"></script>
<script src="./script/aws-cognito-sdk.min.js"></script>
<script src="./script/amazon-cognito-identity.min.js"></script>
@SumindaD
SumindaD / S3ComprehendMedicalLambda.py
Created July 10, 2019 06:49
Text file S3 triggered lambda processes the file and creates the result in a new text file in same S3 location
import json
import urllib.parse
import boto3
import os
print('Loading function')
s3 = boto3.client('s3')
comprehend = boto3.client('comprehendmedical')
from __future__ import print_function
import re
def lambda_handler(event, context):
print("Client token: " + event['authorizationToken'])
print("Method ARN: " + event['methodArn'])
principalId = 'user:test'
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:
name: aws
iamManagedPolicies:
- arn:aws:iam::aws:policy/AmazonSNSFullAccess
- arn:aws:iam::aws:policy/AmazonTextractFullAccess
- arn:aws:iam::aws:policy/AmazonS3FullAccess
runtime: ${self:custom.lambdaRunTime}
versionFunctions: false
region: us-east-1
plugins:
- serverless-pseudo-parameters
layers:
boto3Layer:
path: lib/boto3
name: boto3-layer
description: Boto3 layer for stage
compatibleRuntimes:
- ${self:custom.lambdaRunTime}