Skip to content

Instantly share code, notes, and snippets.

You are now aware that you are breathing

Brian LeRoux brianleroux

You are now aware that you are breathing
View GitHub Profile
brianleroux / .arc-config
Created Sep 15, 2020
examle .arc-config with multiple policies
View .arc-config
runtime python3.7
memory 256
timeout 3
concurrency 1
View sam-ws-fun.json
"AWSTemplateFormatVersion": "2010-09-09",
"Transform": "AWS::Serverless-2016-10-31",
"Description": "Exported by architect/package@2.0.0-RC.0 on 2020-07-13T17:10:57.465Z",
"Resources": {
"HTTP": {
"Type": "AWS::Serverless::HttpApi",
"Properties": {
"StageName": "$default",
"DefinitionBody": {
View foo.js
// sign up save the data by creating a dynamic index..
await begin.set([
{table: `users`, key: userID, email, name, etc},
{table: `user-${ email }`, key: userID, email, name, etc}
brianleroux / .arc-env
Created Mar 23, 2020
working local with env vars
View .arc-env
# ensure this file is in your .gitignore
# example .arc-env
MYVAR asdfasdf
MYVAR2 blah
MYVAR2 foo

What's the best way to invoke another function? (or get it's ARN)

reccomend using @events or @queues for 'background tasks' (events are SNS topics, unordered ans async…queues are SQS fifo queues)

is it safe to put await arc.tables() outside the event handler of a function?

you can, it will make a one time call to SSM to resolve generated table names with the names defined .arc but generally I'd reccomend keeping things deterministic as possible and doing it in the main function body

how does specifying a ddb trigger look?

View demo.js
// get the client
let data = await arc.tables()
// get the generated table names
let tables = await data.reflect()
// use the document client directly
data._doc.batchGet({TableName: tables.mytable ...})
View example-o-pagination-ddb.js
let aws = require('aws-sdk')
let region = 'us-west-1'
let db = new aws.DynamoDB.DocumentClient({region})
TableName: 'begin-production-builds',
IndexName: 'begin-production-builds-appID_env-ts-index',
KeyConditionExpression: '#appID_env = :appID_env',
ExpressionAttributeNames: {
'#appID_env': 'appID_env'
brianleroux /
Last active Dec 8, 2019
playing around w HTTP apis for API Gateway…try saying that three times fast

create a $default route lambda

run sam deploy --template-file sam.yaml --stack-name Hi --capabilities CAPABILITY_IAM to see the default route…the invoke persmission will be invalid but even brute forcing it fails

brianleroux / get-lambdas.js
Created Oct 23, 2019
use the aws-sdk to list all your lambda functions in a stack
View get-lambdas.js
let aws = require('aws-sdk')
let cfn = new aws.CloudFormation
let StackName = 'your stackname here'
let isLambda = i=> i.ResourceType === 'AWS::Lambda::Function'
let resources = await cfn.listStackResources({StackName}).promise()
let functions = data.StackResourceSummaries.filter(isLambda)
brianleroux / .arc
Created Oct 12, 2019
example bucket config
View .arc
bucket my-bucket-in-east-1
region us-east-1
profile myprofile