Skip to content

Instantly share code, notes, and snippets.

View alexcasalboni's full-sized avatar
✌️
Happy coding!

Alex Casalboni alexcasalboni

✌️
Happy coding!
View GitHub Profile
@alexcasalboni
alexcasalboni / deploy.sh
Last active January 29, 2024 12:22
Simple AWS Lambda deployment script - Zip & upload Deployment Package with initial dependencies to S3
#!/bin/bash
BUCKET="YOUR_BUCKET_NAME" # bucket name
FILENAME="deployment-package.zip" # upload key
TMP_FOLDER="/tmp/lambda-env-tmp/" # will be cleaned
OUTPUT_FOLDER="/tmp/lambda-env/" # will be cleaned
HERE=${BASH_SOURCE%/*} # relative path to this file's folder
LAMBDA_FOLDER="$HERE/lambda/" # relative path
@alexcasalboni
alexcasalboni / boto3_getpolicy.py
Last active August 20, 2017 03:53
AWS IAM Policy body with Python and boto3
import boto3
iam = boto3.resource('iam')
def get_policy_body(arn, version_id=None):
""" Return IAM Policy JSON body """
if version_id:
version = iam.PolicyVersion(arn, version_id)
else:
policy = iam.Policy(arn)
@alexcasalboni
alexcasalboni / index.md
Last active November 30, 2022 06:22
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.

Notes

@alexcasalboni
alexcasalboni / amazon-rekognition.md
Last active October 11, 2024 16:44
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
alexcasalboni / aws-lambda-edge.md
Last active July 25, 2024 22:45
Serve dynamically generated, minimized and compressed HTML pages with AWS Lambda@Edge.

AWS Lambda@Edge Experiment

Requirements

  • 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
alexcasalboni / tweets.json
Last active July 4, 2017 14:06
Serverless Highlights of 2017 - 1/2
[
"https://twitter.com//goserverless/status/879729046568882177",
"https://twitter.com//zdne/status/879726263417663490",
"https://twitter.com//jeffconf/status/879722357899894785",
"https://twitter.com//AzureFunctions/status/879458907453767680",
"https://twitter.com//adampash/status/877549817471279105",
"https://twitter.com//MongoDB/status/877186132404031488",
"https://twitter.com//alex_casalboni/status/875866754177748993",
"https://twitter.com//gmolto/status/872691887936811008",
"https://twitter.com//jeffconf/status/872451904642703360",
@alexcasalboni
alexcasalboni / ml.py
Created July 21, 2017 10:26
AmazonML Lab updated code
import boto3
from boto3.session import Session
session = Session(aws_access_key_id='AWS_ACCESS_KEY_ID', aws_secret_access_key='AWS_SECRET_ACCESS_KEY')
machinelearning = session.client('machinelearning', region_name='us-east-1')
labels = {'1': 'walking', '2': 'walking upstairs', '3': 'walking downstairs', '4': 'sitting', '5': 'standing', '6': 'laying'}
# fill your model ID and Endpoint here!
model_id = 'MODEL_ID'
prediction_endpoint = 'MODEL_ENDPOINT'
@alexcasalboni
alexcasalboni / serverless-resources.yml
Created January 4, 2018 20:51
Serverless Resources sample for Amazon Cognito IdentityPool
Resources:
WorkshopKinesisStream:
Type: "AWS::Kinesis::Stream"
Properties:
ShardCount: 1
IdentityPool:
Type: "AWS::Cognito::IdentityPool"
Properties:
IdentityPoolName: WorkshopIdentityPool
@alexcasalboni
alexcasalboni / aws-lambda-static-type-checker.md
Last active May 22, 2023 07:31
AWS Lambda Static Type Checker Example (Python3)

How to use Python3 Type Hints in AWS Lambda

TL;DR

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

Your Lambda Function code will go from this:

@alexcasalboni
alexcasalboni / aws-sam-automatic-rollback-demo.md
Last active March 22, 2023 05:27
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)