Skip to content

Instantly share code, notes, and snippets.

version: 0.2
phases:
install:
runtime-versions:
nodejs: 10
pre_build:
commands:
- npm install
build:
@allenheltondev
allenheltondev / Twilio Christmas REST State Machine Flow.json
Created December 17, 2019 13:28
Twilio Flow state machine that calls out to a REST service for logic and notifies the user of a response
{
"description": "My Christmas Gift Flow",
"states": [
{
"name": "Trigger",
"type": "InitialState",
"properties": {
"offset": {
"x": 380,
"y": 70
@allenheltondev
allenheltondev / AWS Serverless Cost Breakdown.csv
Last active March 11, 2020 03:00
AWS Serverless Cost Breakdown
AWS Service Cost Per Invocation Type Cost Formula
API Gateway Request 0.0000035 Compute $3.50 / million
API Gateway Data Transfer (1KB) 0.00000009 Compute $.09 / GB
Lambda Execution 0.0000002 Compute $.20 / million invocations
Lambda Compute (300ms, 128MB) 0.00000067 Compute (.3 seconds * .125 GB) * .0000167
DDB Write Capacity Unit (1 / Month) 0.468 Compute $.00065 per hour ( x 24 hrs x 30 days)
DDB Read Capacity Unit (1 / Month) 0.0936 Compute $.00013 per hour ( x 24 hrs x 30 days)
DDB Stream Reads 0.0000002 Compute $.02 / 100,000
DDB Storage (1KB /Month) 0.00000025 Storage $.25 / GB / month
DDB Backup (1KB/Month PITR) 0.00000024 Storage $.20 / GB / month
{
"dependencies": {
"twilio": "^3.39.3",
"http-status-codes": "^1.3.2"
}
}
DependencyLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: dependency-layer
ContentUri: dependencies/
CompatibleRuntimes:
- nodejs12.x
RetentionPolicy: Retain
FunctionLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: FunctionLayer
ContentUri: layers/
CompatibleRuntimes:
- nodejs12.x
RetentionPolicy: Retain
Globals:
Function:
Layers:
- !Ref FunctionLayer
- !Ref DependencyLayer
Runtime: nodejs12.x
Timeout: 10
Tracing: Active
// Pulls from Dependency Layer - Declared like normal
const Twilio = require('twilio');
const short = require('short-uuid');
const httpStatusCode = require('http-status-codes');
// Pulls from Function Layer - Must pull from 'opt/nodejs/<filename>'
const db = require('/opt/nodejs/database');
{
"description": "<Your company here>",
"states": [
{
"name": "Trigger",
"type": "InitialState",
"properties": {
"offset": {
"x": 20,
"y": -170