Skip to content

Instantly share code, notes, and snippets.

View patrickbrandt's full-sized avatar

Patrick Brandt patrickbrandt

View GitHub Profile
@patrickbrandt
patrickbrandt / 02_demo_test_publish.sh
Last active December 11, 2020 22:28
Jenkins routines for AWS Lambda + API Gateway
# This is a "Managed Script" in Jenkins
COMMIT=`aws lambda get-alias --region $AWS_REGION --function-name $FUNCTION_NAME --name $PUBLISH_FROM_ALIAS | grep "Description" | cut -d'"' -f4`
VERSION=`aws lambda publish-version --region $AWS_REGION --function-name $FUNCTION_NAME --description $COMMIT | grep "Version" | cut -d'"' -f4`
aws lambda update-alias --region $AWS_REGION --function-name $FUNCTION_NAME --function-version $VERSION --name $PUBLISH_TO_ALIAS --description $COMMIT
@patrickbrandt
patrickbrandt / PointCriteria.md
Created August 5, 2018 21:54
PBP-PointCriteria
Points Complexity The software developer’s perspective
1 XS
@patrickbrandt
patrickbrandt / python_aws_lambda_config.md
Last active November 6, 2022 10:14
A simple approach to multi-environment configurations for AWS Lambda functions

AWS recently released Versioning and Aliases for Lambda Functions. I'm going to outline how I've taken advantage of this to provide environmentally-aware Lambda function configurations in Python.

AWS Lambda doesn't currently support environment variables, so 12-factor-style configuration isn't an option. I'll be using seprate config files for each environment.

Pregame

We're making two assumptions for this article:

  • I've already created an AWS Lambda function with the following aliases:
    • Dev
    • Test
    • Staging
    • Production
@patrickbrandt
patrickbrandt / essential_links.md
Last active May 17, 2023 22:42
Essential Links
@patrickbrandt
patrickbrandt / service-worker-example.html
Last active May 17, 2023 22:43
Simple Service Worker didactic POC - caching outbound requests
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
if (!navigator.serviceWorker.controller) {
navigator.serviceWorker.register('/sw.js', { scope: '.'}).then(function(registration) {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
window.location.reload();
}).catch(function(err) {
console.log('ServiceWorker registration failed: ', err);
@patrickbrandt
patrickbrandt / socket.io_Express_Angular.md
Last active August 30, 2023 21:28
Simple socket.io integration with Express + Angular

Socket.io integration between an Express and Angular app is a breeze. I'll outline the Express implementation first, then outline Angular integration.

Express + socket.io

Reference socket.io in layout.jade

npm install socket.io --save and then reference socket.io in your layout.jade file:

doctype html
html(ng-app="example")
  head
    title= title
@patrickbrandt
patrickbrandt / S3-readonly-bucket.json
Created November 22, 2016 18:21
IAM Policy for read-only S3 bucket access
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowUserToSeeBucketListInTheConsole",
"Action": [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
"Effect": "Allow",