This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib2, argparse, os, sys, json | |
from oauth2client import tools, file, client | |
from oauth2client.service_account import ServiceAccountCredentials | |
from googleapiclient import discovery | |
from googleapiclient.errors import HttpError | |
#Project and model configuration | |
project_id = '132567073760' | |
model_id = 'HAR-model' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"DocumentId": "Italy-document-ID", | |
"Attributes": { | |
"_category": "countries", | |
"_created_at": "2009-12-10T06:00:00", | |
"_last_updated_at": "2019-12-10T06:00:00", | |
"_version": "3.0", | |
"_view_count": 40000 | |
}, | |
"Title": "Italy Wikipedia", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def lambda_handler(event, context): | |
name = get_name(event) # extract inputs | |
message = get_message(name) # business logic | |
return build_response(message) # format output for ALB | |
def get_name(event): | |
# fetch inputs from event (could be missing) | |
return event['queryStringParameters'].get('name') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handler(event, context): | |
input = extract_input_from_event('ALB', event) | |
output = my_business_logic(input) | |
return format_output_for('ALB', output) | |
def extract_input_from_event(alb_or_apigw, event): | |
# extract data from input event | |
def format_output_for(alb_or_apigw, output): | |
# return a json object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"statusCode": 200, | |
"statusDescription": "200 OK", | |
"isBase64Encoded": false, | |
"headers": { | |
"Content-Type": "application/json" | |
}, | |
"body": "{\"message\": \"Hello world!\"}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"requestContext": { | |
"elb": { | |
"targetGroupArn": "arn:aws:elasticloadbalancing:XXX:YYY:targetgroup/lambda-ZZZ" | |
} | |
}, | |
"httpMethod": "GET", | |
"path": "/my-new-feature", | |
"queryStringParameters": { | |
"id": "123" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion : '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Resources: | |
myHookFunction: | |
Type: AWS::Serverless::Function | |
Properties: | |
Handler: index.handler | |
# ... | |
# all the other properties here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myAppSettings: | |
Type: AWS::Pinpoint::ApplicationSettings | |
Properties: | |
ApplicationId: !Ref myPinpointApp | |
CampaignHook: | |
LambdaFunctionName: !Ref myHookFunction | |
Mode: FILTER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion : '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Resources: | |
myHookFunction: | |
Type: AWS::Serverless::Function | |
Properties: | |
Handler: index.handler | |
# ... | |
# all the other properties here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion : '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Resources: | |
myPipelineFunction: | |
Type: AWS::Serverless::Function | |
Properties: | |
Handler: index.handler | |
Policies: | |
- AWSLambdaExecute # Managed Policy |