Skip to content

Instantly share code, notes, and snippets.

View singledigit's full-sized avatar

Eric Johnson singledigit

View GitHub Profile
@singledigit
singledigit / gist:cfcd8bc6a1ed421c6b6b1196f189931d
Created April 5, 2023 15:32
Non-proxy catch all endpoint
openapi: "3.0.1"
info:
title: "vtl-example"
version: "1.0"
servers:
- url: "https://r5aji4fod4.execute-api.us-west-2.amazonaws.com/{basePath}"
variables:
basePath:
default: "/Prod"
paths:
@singledigit
singledigit / handler.py
Last active February 24, 2023 06:04
boto sigv4 in python with Lambda
import boto3
import json
import requests
from requests_aws4auth import AWS4Auth
def lambda_handler(event, context):
signature = get_signature()
return fetch(signature)
def get_signature():
@singledigit
singledigit / README.md
Last active September 27, 2022 17:18
AWS SAM direct integration of API Gateway REST to Amazon SQS

Instructions

  1. Drop both these files in the same folder.
  2. Deploy using AWS SAM
sam deploy --guided
@singledigit
singledigit / Data Source.json
Created May 7, 2021 04:34
AppSync HTTP resolver - StartSyncExecution for StepFunctions express workflows
{
"apiId": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
"name": "sync_step_function",
"description": "step function test",
"type": "HTTP",
"serviceRoleArn": "arn:aws:iam::xxxxxxx:role/appsync-step-function",
"httpConfig": {
"endpoint": "https://sync-states.us-east-2.amazonaws.com",
"authorizationConfig": {
"authorizationType": "AWS_IAM",
@singledigit
singledigit / Install-AWS-SAM.sh
Last active February 23, 2024 23:16
Install AWS SAM on Linux using the new Linux installer
curl -L https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip -o aws-sam-cli-linux-x86_64.zip
unzip aws-sam-cli-linux-x86_64.zip -d sam-installation
sudo ./sam-installation/install
where sam
sam --version
@singledigit
singledigit / get-vars.py
Last active April 12, 2023 14:13
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 `./get-vars.py MyStack > vars.json`
import sys, json
import boto3
if len(sys.argv) == 1:
@singledigit
singledigit / api.yaml
Created September 24, 2020 17:42
Example of an AWS Lambda Destinations configuration for AWS Lambda functions within an application.
# You don't need this, but here it is anyways :)
openapi: "3.0.1"
info:
title: "Translation API (Async)"
version: "1.0.0"
paths:
/:
post:
summary: Create new translation request
@singledigit
singledigit / template.yaml
Created August 18, 2020 22:06
Creating an EventBridge rule with API Gateway as the target in AWS SAM
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Event Bridge -> API Gateway
Resources:
RestApiGateway:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
@singledigit
singledigit / RequestTemplate-vtl.json
Last active November 6, 2020 18:50
Example of using VTL on Amazon API Gateway to insert an epoch time into Amazon DynamoDB to be used as a TTL field
## 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 )
{
"TableName":"Epoch",
"Item":{
"id":{"S":"$context.requestId"},
"ttlTime":{"N":"$epoch"}
}
@singledigit
singledigit / template.yaml
Created August 11, 2020 23:24
Using a DynamoDB CloudFormation resource in a SAM template to add range.
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: DDB example
Resources:
Table:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: id