Skip to content

Instantly share code, notes, and snippets.


Eric Johnson singledigit

View GitHub Profile
singledigit / Data Source.json
Created May 7, 2021
AppSync HTTP resolver - StartSyncExecution for StepFunctions express workflows
View Data Source.json
"apiId": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
"name": "sync_step_function",
"description": "step function test",
"type": "HTTP",
"serviceRoleArn": "arn:aws:iam::xxxxxxx:role/appsync-step-function",
"httpConfig": {
"endpoint": "",
"authorizationConfig": {
"authorizationType": "AWS_IAM",
singledigit /
Last active Feb 15, 2021
Install AWS SAM on Linux using the new Linux installer
curl -L -o
unzip -d sam-installation
sudo ./sam-installation/install
where sam
sam --version
singledigit /
Last active Jul 15, 2021
Get all env variables for all AWS Lamda functions in a CloudFormation/SAM stack
#! /usr/bin/env python
# Use at your own risk and reward.
# requires boto3 to be installed
# example `./ MyStack > vars.json`
import sys, json
import boto3
if len(sys.argv) == 1:
singledigit / api.yaml
Created Sep 24, 2020
Example of an AWS Lambda Destinations configuration for AWS Lambda functions within an application.
View api.yaml
# You don't need this, but here it is anyways :)
openapi: "3.0.1"
title: "Translation API (Async)"
version: "1.0.0"
summary: Create new translation request
singledigit / template.yaml
Created Aug 18, 2020
Creating an EventBridge rule with API Gateway as the target in AWS SAM
View template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Event Bridge -> API Gateway
Type: AWS::Serverless::Api
StageName: Prod
singledigit / RequestTemplate-vtl.json
Last active Nov 6, 2020
Example of using VTL on Amazon API Gateway to insert an epoch time into Amazon DynamoDB to be used as a TTL field
View RequestTemplate-vtl.json
## This examples converts the millisecond epoch of API Gateway
## to the seconds epoch of DynamoDB and adds 5 minutes for the TTL.
#set( $epoch = $context.requestTimeEpoch / 1000 + 300 )
singledigit / template.yaml
Created Aug 11, 2020
Using a DynamoDB CloudFormation resource in a SAM template to add range.
View template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: DDB example
Type: AWS::DynamoDB::Table
- AttributeName: id
singledigit /
Last active Apr 25, 2020
Testing a Lambda function locally against DynamoDB on AWS.

Local development with SAM

This method allows you to iterate very quickly against Lambda code without having to run AWS resources locally.


Step 1: Create and deploy a simple SAM Template (see template.yaml)

  • must include the environment varibales on the Lambda to pass the SAMPLE_TABLE in (see line 17)
  • use sam deploy --guided for the first time deploy
View sam-http-api.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: HTTP API test
Timeout: 3
Type: AWS::Serverless::Function
singledigit / handler.js
Created Oct 15, 2019
Lambda API Gateway Response Handler
View handler.js
const isLocal = process.env.AWS_SAM_LOCAL;
const handlerModel = (body, headers, code) => {
let response = {
'statusCode': code,
'body': JSON.stringify(body)
if(headers.length > 0) {
response.headers = response.headers || {};