Skip to content

Instantly share code, notes, and snippets.

Happy coding!

Alex Casalboni alexcasalboni

Happy coding!
View GitHub Profile
alexcasalboni /
Last active Oct 14, 2020
AWS Lambda Static Type Checker Example (Python3)

How to use Python3 Type Hints in AWS Lambda


Static Type Checkers help you find simple (but subtle) bugs in your Python code. Check out and incrementally improve your code base and development/debugging experience with type hints.

Your Lambda Function code will go from this:

alexcasalboni /
Last active Oct 3, 2020
AWS Lambda Power Tuning - Demo Setup
# config
# package
sam package --s3-bucket $BUCKET_NAME --template-file template.yml --output-template-file packaged.yml
# deploy
sam deploy --template-file packaged.yml --stack-name $STACK_NAME --capabilities CAPABILITY_AUTO_EXPAND CAPABILITY_IAM
alexcasalboni /
Last active Oct 1, 2020
Amazon Rekognition - Python Code Samples

Amazon Rekognition - Python Code Samples

  1. Labels Detection
  2. Faces Detection
  3. Faces Comparison
  4. Faces Indexing
  5. Faces Search
alexcasalboni /
Last active Sep 15, 2020
Bridge Function between Kinesis Streams and Step Functions

Bridge Function between Kinesis Streams and Step Functions

For each record read from the Kinesis Stream, a StepFunction state machine will be executed asynchronously.

Required Environment Variables

  • region: the AWS region where your StepFunction state machine is defined.
  • stateMachineArn: the ARN of the StepFunction state machine you want to execute.


alexcasalboni /
Created May 29, 2019
Amazon Lex fulfillment function - Lambda handler (Python) + utilities
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()
def lambda_handler(event, context):
logger.debug('', event['bot']['name'])
logger.debug('userId=%s, intentName=%s', event['userId'], event['currentIntent']['name'])
alexcasalboni / listPricingByRegion.js
Last active May 5, 2020
AWS Pricing API - Fetch AWS Step Functions price for all regions
View listPricingByRegion.js
const AWS = require('aws-sdk');
const pricing = new AWS.Pricing({region: 'us-east-1'});
const main = async () => {
const output = {};
const prices = await pricing.getProducts({
ServiceCode: "AmazonStates",
alexcasalboni /
Last active Mar 18, 2020
Serve dynamically generated, minimized and compressed HTML pages with AWS Lambda@Edge.

AWS Lambda@Edge Experiment


  • AWS Lambda@Edge (enabled Preview)
  • One Amazon CloudFront Distribution (origin doesn't matter)
  • IAM role (basic execution is enough)
  • npm to install Node.js dependencies
alexcasalboni /
Last active Mar 8, 2020
AWS SAM Demo - Automatic Rollback for AWS Lambda with AWS CodeDeploy

How to Build and Deploy Serverless Apps [AWS Summit]

This demo was presented at the AWS Summit @ Cape Town on Jul 12th.

You can find the slides here.

What's included in this Gist?

  • index.js: The node.js code used for AWS Lambda
  • sam_template.yaml: The AWS SAM template in YAML format (i.e. CloudFormation)
alexcasalboni /
Last active Jan 21, 2020
Google Prediction API - Train a classification model and generate a new Prediction
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'
You can’t perform that action at this time.