Skip to content

Instantly share code, notes, and snippets.

View PopeFelix's full-sized avatar

Aurelia Peters PopeFelix

View GitHub Profile
@PopeFelix
PopeFelix / list-lambdas-by-tag.ts
Created July 19, 2022 22:40
List AWS Lambdas by tag
import Log from "@dazn/lambda-powertools-logger"
import {
LambdaClient,
ListFunctionsCommand,
ListFunctionsCommandOutput,
ListTagsCommand,
} from "@aws-sdk/client-lambda"
const lambda = new LambdaClient({})
@PopeFelix
PopeFelix / Dockerfile
Created August 26, 2021 15:43
Docker with Locust and S3FS
# I want to run Locust (https://locust.io) inside of a Fargate container and pulling the Locustfile from S3.
# My thought was that I would use S3FS to do that, but that requires privileged mode, which Fargate doesn't
# do. So S3FS isn't going to work, but I thought putting the Dockerfile up here might prove useful at some point.
FROM paterit/locustio AS base
RUN apk update
RUN apk add --no-cache \
fuse \
curl \
libxml2
@PopeFelix
PopeFelix / configFromSsm.ts
Created January 28, 2021 21:32
Take a configuration stored in SSM as a series of hierarchical path / value pairs and return it as an object
// Take a configuration stored in SSM as a series of hierarchical path / value pairs and return it as an object
import {
GetParametersByPathCommand,
GetParametersByPathCommandOutput,
SSMClient,
} from '@aws-sdk/client-ssm
async function getBackupConfig = async (parameterRoot: string) => {
const ssm = new SSMClient({})
let NextToken: string
// A sketch demonstrating a way to take "/" delimited paths (e.g. '/foo/bar', '/foo/baz', '/foo/bak/quux', '/foo/bak/quuy')
// and put them into a single object where the keys match the path hierarchy.
const pathVals = { '/foo/bar/baz': 1, '/foo/bar/bak': 2, '/foo/quux': 11, '/alpha': 13 }
// Expected:
//{
// foo: {
// bar: {
// baz: 1,
@PopeFelix
PopeFelix / jsongzip.js
Created October 13, 2020 16:47
encode / decode gzipped JSON
const util = require('util');
const zlib = require('zlib');
const gzip = util.promisify(zlib.gzip);
const gunzip = util.promisify(zlib.gunzip);
const encodeGzippedJson = async (obj) => {
const gzBuf = await gzip(JSON.stringify(obj));
return JSON.stringify(gzBuf);
}
@PopeFelix
PopeFelix / interpolateServerless.js
Created May 20, 2020 16:21
Interpolate custom vars in serverless.yml
/*
This came about because I needed to get a VPC name that was a function of the deployment stage
(e.g. 'my-vpc-dev', 'my-vpc-qa', etc.). I could have just hardcoded the VPC name in serverless.yml and edited it for
each deploy, but where's the fun in that?
What this does is to take a value from serverless.yml like "my-vpc-${self:custom.stage}" and interpolate the variable
"${self:custom.stage}" embedded therein. This variable could resolve to another variable, so it gets called recursively.
Note that the construction "${opt:stage, self:provider.stage}" should be interpreted as
${opt:stage} || ${self:provider.stage}
*/
Computer Information:
Manufacturer: Unknown
Model: Unknown
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: GenuineIntel
CPU Brand: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
CPU Family: 0x6
@PopeFelix
PopeFelix / customResource.js
Created April 3, 2020 01:41
Custom CFN resource in Serverless
const { customResourceHelper, ResourceHandler, ResourceHandlerReturn } = require('custom-resource-helper')
module.exports.handler = customResourceHelper(() => ({
onCreate: async (event, context, logger) => {
// Place your code to handle Create events here.
const physicalResourceId = 'myResourceId'
const responseData = {}
console.log('CREATE event: ', event)
console.log('Logger: ', logger)
return {
physicalResourceId,
@PopeFelix
PopeFelix / cloudSettings
Last active March 25, 2020 16:58
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-03-25T16:56:24.822Z","extensionVersion":"v3.4.3"}
@PopeFelix
PopeFelix / github-webhook-listener.js
Created February 21, 2020 18:00
Github webhook listener using Node.js and Express.
const express = require('express')
const app = express()
const port = 80
const bodyParser = require('body-parser')
const crypto = require('crypto')
const secret = process.env.WEBHOOK_SECRET
app.use(
bodyParser.urlencoded({
extended: true
})