Skip to content

Instantly share code, notes, and snippets.

View brianleroux's full-sized avatar
💚
You are now aware that you are breathing

Brian LeRoux brianleroux

💚
You are now aware that you are breathing
View GitHub Profile
{
"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": {
// 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
brianleroux / .arc-env
Created March 23, 2020 17:55
working local with env vars
# ensure this file is in your .gitignore
# example .arc-env
@testing
MYVAR asdfasdf
MYVAR2 blah
@staging
MYVAR val
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?

// 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 ...})
let aws = require('aws-sdk')
let region = 'us-west-1'
let db = new aws.DynamoDB.DocumentClient({region})
db.query({
TableName: 'begin-production-builds',
IndexName: 'begin-production-builds-appID_env-ts-index',
KeyConditionExpression: '#appID_env = :appID_env',
ExpressionAttributeNames: {
'#appID_env': 'appID_env'
@brianleroux
brianleroux / readme.md
Last active December 8, 2019 02:38
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
brianleroux / get-lambdas.js
Created October 23, 2019 21:17
use the aws-sdk to list all your lambda functions in a stack
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
brianleroux / .arc
Created October 12, 2019 20:17
example bucket config
@app
myapp
@aws
bucket my-bucket-in-east-1
region us-east-1
profile myprofile
add arc locally
```bash
npm init -f
npm i @architect/architect
```
edit `package.json` with a startup script
```