Skip to content

Instantly share code, notes, and snippets.

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

Aidan Steele aidansteele

🏠
Working from home
View GitHub Profile
@aidansteele
aidansteele / worker.js
Last active April 12, 2022 06:48
example of using a cloudflare worker (for custom domains) in front of a lambda fURL
const furlDomain = "lf4rhhulpamois3oz5z4i3anpe0loidx.lambda-url.us-east-2.on.aws";
async function handleRequest(request) {
const url = new URL(request.url);
url.hostname = furlDomain;
const newRequest = new Request(url, request);
newRequest.headers.set('Host', furlDomain);
return await fetch(newRequest);
Transform: AWS::Serverless-2016-10-31
Resources:
Function:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.9
Handler: index.handler
InlineCode: |
import json
@aidansteele
aidansteele / bus-account-a.yml
Last active October 7, 2021 02:51
cross-account eventbus design
Resources:
Bus:
Type: AWS::Events::EventBus
BusPolicy:
Type: AWS::Events::EventBusPolicy
Properties:
EventBusName: !Ref Bus
StatementId: AllowOrg
Statement:
@aidansteele
aidansteele / example.yml
Created July 20, 2021 00:51
example http api gw w/ iam auth
Transform: AWS::Serverless-2016-10-31
Resources:
Function:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.8
Handler: index.handler
InlineCode: |
def handler(a, b):
Parameters:
SecurityGroupIds:
Type: List<AWS::EC2::SecurityGroup::Id>
SubnetIds:
Type: List<AWS::EC2::Subnet::Id>
Resources:
Api:
Type: AWS::ApiGatewayV2::Api
Properties:
@aidansteele
aidansteele / amazonaws.com domains
Last active February 2, 2021 18:20
some amazonaws.com domains
generation process:
* go to https://crt.sh/?q=%25.amazonaws.com
* dump into a text document
* de-dupe regions by replacing us-east-1, ap-southeast-2, etc with "region"
* de-dupe ec2 by replacing ec2-123-45-67-89 with ec2-xx-xx-xx-xx
* also check out https://gist.github.com/phils/eefcc8b1dcbaf9e5cec4fb98b9413c7b for an even more digestible version
*.?.?.?.amazonaws.com
@aidansteele
aidansteele / userdata.sh
Created March 26, 2018 07:58
userdata to use nvme disk for docker instead of ebs
set -euxo pipefail
service docker stop
vgextend docker /dev/nvme0n1
lvremove -f /dev/docker/docker-pool
vgreduce docker /dev/sdcz1
lvcreate -T docker -n docker-pool -L 200G
lvcreate docker -n scratch -L 200G
mkfs.ext4 -E nodiscard /dev/docker/scratch
mkdir /mnt/scratch
@aidansteele
aidansteele / sort_ecs_tasks_by_mem.py
Created February 27, 2018 22:11
sort ecs tasks in a cluster by memory reservation
#!/usr/bin/env python3
import boto3
import json
import sys
import os
import itertools
def chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i + n]
MacBookPro2017:linkerd aidan$ time ./sbt compile
Getting org.scala-sbt sbt 0.13.16 ...
downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.16/jars/sbt.jar ...
[SUCCESSFUL ] org.scala-sbt#sbt;0.13.16!sbt.jar (5481ms)
downloading https://jcenter.bintray.com/org/scala-lang/scala-library/2.10.6/scala-library-2.10.6.jar ...
[SUCCESSFUL ] org.scala-lang#scala-library;2.10.6!scala-library.jar (2939ms)
downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/main/0.13.16/jars/main.jar ...
[SUCCESSFUL ] org.scala-sbt#main;0.13.16!main.jar (6141ms)
downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/compiler-interface/0.13.16/jars/compiler-interface.jar ...
[SUCCESSFUL ] org.scala-sbt#compiler-interface;0.13.16!compiler-interface.jar (5975ms)
@aidansteele
aidansteele / automation.yml
Created September 4, 2017 00:21
aws-updatewindowsami in yaml
---
schemaVersion: '0.3'
description: Updates a Microsoft Windows AMI. By default it will install all Windows
updates, Amazon software, and Amazon drivers. It will then sysprep and create a
new AMI. Supports Windows Server 2008 R2 and greater.
assumeRole: "{{ AutomationAssumeRole }}"
parameters:
SourceAmiId:
type: String
description: "(Required) The source Amazon Machine Image ID."