This file contains hidden or 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
SELECT * | |
FROM weather_mapping | |
WHERE | |
weather = lambda_sync ( | |
'arn:aws:lambda:REGION:ACCOUNT_ID:function:FetchWeather', | |
'{ "location" : "London" }' | |
) |
This file contains hidden or 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
DROP TRIGGER IF EXISTS TR_contacts_on_insert; | |
DELIMITER ;; | |
CREATE TRIGGER TR_contacts_on_insert | |
AFTER INSERT ON Contacts | |
FOR EACH ROW | |
BEGIN | |
SELECT NEW.email , NEW.fullname | |
INTO @Email , @Fullname; | |
lambda_async( | |
'arn:aws:lambda:REGION:ACCOUNT_ID:function:SendEmailWithContact', |
This file contains hidden or 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
GRANT INVOKE LAMBDA ON *.* TO user@domain-or-ip-address |
This file contains hidden or 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: | |
MyProcessingFunction: | |
Type: AWS::Serverless::Function | |
Properties: | |
Handler: index.handler | |
Runtime: python3.7 | |
Policies: | |
- AWSLambdaExecute # Managed Policy |
This file contains hidden or 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 time | |
import boto3 | |
from decode import decode # see decode.py | |
cloudwatch_logs = boto3.client('logs') | |
def handler(event, context): | |
obj = decode(event['awslogs']['data']) | |
# wait for other logs to be collected in the stream |
This file contains hidden or 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
{ | |
"messageType": "DATA_MESSAGE", | |
"owner": "123456789123", | |
"logGroup": "myLogGroup", | |
"logStream": "myLogStream", | |
"subscriptionFilters": [ | |
"mySubscriptionFilter" | |
], | |
"logEvents": [ | |
{ |
This file contains hidden or 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
const zlib = require('zlib'); | |
exports.decode = async (data) => { | |
const compressedPayload = Buffer.from(data, 'base64'); | |
const jsonPayload = zlib.gunzipSync(compressedPayload).toString('utf8'); | |
return JSON.parse(jsonPayload); | |
} |
This file contains hidden or 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
{ | |
"awslogs": { | |
"data": "_BASE64_AND_ZIPPED_DATA_" | |
} | |
} |
This file contains hidden or 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 logging | |
from lex_utils import elicit_slot, delegate, close, ElicitAction, DelegateAction | |
from utils import validate_dialog, init_or_load_session, finalize_session, actually_book_the_hotel | |
logger = logging.getLogger() | |
logger.setLevel(logging.DEBUG) | |
def lambda_handler(event, context): | |
logger.debug('event.bot.name=%s', event['bot']['name']) | |
logger.debug('userId=%s, intentName=%s', event['userId'], event['currentIntent']['name']) |
This file contains hidden or 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
from lex_utils import elicit_slot, delegate, close, ElicitAction, DelegateAction | |
from utils import validate_dialog, init_or_load_session, finalize_session, actually_book_the_hotel | |
def lambda_handler(event, context): | |
intent_name = event['currentIntent']['name'] | |
if intent_name == 'BookHotel': | |
return book_hotel(event) | |
# elif (add more intents here) |