Skip to content

Instantly share code, notes, and snippets.

View alexturek's full-sized avatar
🍠

Alex Turek alexturek

🍠
  • Seattle, WA, USA
View GitHub Profile
@alexturek
alexturek / AWS-Batch-To-SQS.md
Last active September 26, 2022 21:44
How to configure AWS Batch job state updates so they go into an SQS queue

What this is good for

This is Terraform and Python code to help you track AWS Batch Jobs without having to poll Batch's APIs.

It sets up this integration

AWS Batch --(job state change)--> EventBridge --(message)--> SQS
@alexturek
alexturek / delete-queue.sh
Last active January 8, 2018 21:25
Deletes all SQS topics prefixed by something
#!/usr/bin/env bash
# Delete all SQS queues with a specified prefix (up to 1000 at a time)
# SQS won't list more than 1000 queues at a time, so you may need to run this multiple times.
# Usage
#
# ./delete-sqs-queues-like.sh test-
#
# Requires `parallel` and `awscli`
@alexturek
alexturek / delete-test-sns-topics.sh
Last active January 8, 2018 21:23
Deletes all SNS topics prefixed with `test-`. Requires `parallel` and `awscli`
#!/usr/bin/env bash
# Run these first so you have the list of test topics, and you know what you're about to delete
aws sns list-topics | jq -r .Topics[].TopicArn > topics
grep ":test-[[:digit:]]*-" topics > test-topics
sed -r 's/[[:digit:]]/X/g' test-topics | sort | uniq -c
# Actually delete topics:
parallel -j 20 rmtopic.sh < test-topics

ECS Glossary

  • A Service is a homogenous set of Task Definitions. Think of it as a fleet definition. It's responsible for making sure there are enough Tasks (servers or background workers) running at all times. It includes
    • Which Task Definition to run - name + version (e.g. foo-service:30)
    • How many instances of the Task Definition to run
    • Uptime strategies (minimum/maximum healthiness of the fleet)
  • A Task Definition is a definition of how to run a set of docker containers. This includes what volumes to mount, what environment variables to pass into the container, what its CPU/Memory requirements are, port mappings - think everything available as part of the docker run command. Generally we only run one at a time, so we can update services one-type-of-process-at-a-time.
  • A Task is an instance of a running Task Definition. Usually this will be a single docker container. We won't generally run Tasks manually - we let a Service run them for us, aiming
@alexturek
alexturek / method.md
Last active May 20, 2017 01:19
How I validated squel's typings (https://github.com/hiddentao/squel)

From the API examples, in Chrome console:

snippets = $('.syntaxhighlighter.js table')
bits = []; snippets.each((i, snippet) => bits.push(snippet.innerText));
console.log(bits.join('\n'));

After that, I ran ts-node against squel-test.ts until it compiled... and I gave up when I started hititng all the class bits.

@alexturek
alexturek / docker-pg.sh
Last active January 10, 2016 22:58
Run Postgres in docker, but expose it locally like it's native
# Make a VirtualBox VM with enough memory
docker-machine create --driver virtualbox --virtualbox-memory 8096 default
# Map the VirtualBox VM ports 5432 to localhost
VBoxManage controlvm default natpf1 "tcp-port5432,tcp,,5432,,5432"
# If this VM will be reused, bake port mapping into the VM
VBoxManage modifyvm default --natpf1 "tcp-port5432,tcp,,5432,,5432"
# Run a Postgres instance