Skip to content

Instantly share code, notes, and snippets.

View chris's full-sized avatar
🏠
Working from home

Chris Bailey chris

🏠
Working from home
View GitHub Profile
@chris
chris / serverless.yml
Created May 3, 2021 03:53
Cognito user pool authorizer definition in Serverless Framework
functions:
myfunc:
handler: bin/myhandler
events:
- http:
path: myapipath
method: get
authorizer:
type: COGNITO_USER_POOLS
authorizerId:
@chris
chris / events.json
Last active November 23, 2020 19:16
Example of events for our API Gateway to DynamoDB API
{
"event": [
{
"time": "2020-06-16T15:22:33Z",
"lng": -122.03053391,
"lat": 37.33180957,
"uuid": "96a6f48c-fe67-4cad-be24-21d6523137f6",
"sensor_name": "CYT523",
"reading_value": 72.9,
"is_active": true
@chris
chris / apigateway-dynamo-vtl-template_serverless.yml
Last active November 23, 2020 18:52
Just the VTL template portion of the API Gateway - DynamoDB proxy serverless config
RequestTemplates:
application/json: |
#set($inputRoot = $input.path('$'))
{
"RequestItems": {
"${self:resources.Resources.EventsTable.Properties.TableName}": [
#foreach($event in $inputRoot.event)
{
"PutRequest": {
"Item": {
@chris
chris / apigateway-dynamo_serverless.yml
Last active December 17, 2021 05:14
Serverless Framework config file for creating API Gateway to DynamoDB proxy
service: my-api
org: CompanyName
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"
frameworkVersion: '>=2.1.1 <3.0.0'
custom:
defaultStage: dev
@chris
chris / serverless-postman-scripts.yml
Last active September 11, 2020 17:58
Serverless scripts for running Postman tests
custom:
scripts:
commands:
smoke-test-dev: "echo 'activating dev serverless DB and running dev smoke test...'; curl --request GET 'https://YOUR-API-URL' > /dev/null 2>&1; sleep 30; npm run test-dev"
smoke-test-production: "echo 'running production smoke test...'; npm run test-production"
hooks:
'after:deploy:finalize': ${self:custom.scripts.commands.smoke-test-${self:provider.stage}}
@chris
chris / amplify-url-notification.yml
Last active February 24, 2025 19:14
GitHub action to add AWS Amplify URL to PR comments and Slack
name: Amplify Branch URL notifications
on:
create:
pull_request:
types: [opened]
jobs:
add_url_comment:
name: Add Amplify deploy URL to PR comments and Slack
runs-on: ubuntu-latest
@chris
chris / aws_profile_python_config.py
Created August 7, 2020 21:57
AWS SDK configuration with role profile in Python
sess = boto3.session.Session(profile_name='mycompany_somerole_devaccount')
@chris
chris / aws_profile_go_config.go
Last active August 7, 2020 22:05
Go example for configuring AWS SDK with a role based profile
sess := session.Must(session.NewSessionWithOptions(session.Options{
Profile: "mycompany_somerole_devaccount",
SharedConfigState: session.SharedConfigEnable,
}))
@chris
chris / aws_credentials_example
Last active August 7, 2020 22:01
Example ~/.aws/credentials file using role profiles
[mycompany_myiamuser_orgaccount]
aws_access_key_id=ABCDEFGHIJKLMNOPQRST
aws_secret_access_key=abcdefghijklmnopqrstuvwxyz123566789
region=us-west-2
[mycompany_somerole_devaccount]
role_arn=arn:aws:iam::11111111111:role/OrganizationAccountAccessRole
source_profile=mycompany_myiamuser_orgaccount
[mycompany_somerole_prodaccount]
@chris
chris / circleci_config.yml
Created July 7, 2020 20:44
Example of trying to get CircleCI with Postgres, PostGIS and psql working
# Golang CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2
jobs:
build:
docker:
# specify the version
- image: cimg/go:1.14
environment: