Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter Baumgartner ipmb

  • Lincoln Loop
View GitHub Profile
View terraform_crash.log
Error: Error in function call
on .terraform/modules/client_vpc/terraform-aws-vpc-2.39.0/main.tf line 20, in locals:
20: vpce_tags = merge(
21: var.tags,
22: var.vpc_endpoint_tags,
23: )
|----------------
| var.tags is empty map of string
| var.vpc_endpoint_tags is empty map of string
@ipmb
ipmb / push_static_to_s3.py
Created Apr 15, 2020
Django management command to push whitenoise static files to S3, respecting headers
View push_static_to_s3.py
import logging
from concurrent import futures
from typing import List, Tuple
import boto3
from django.conf import settings
from django.core.management import BaseCommand
from whitenoise.middleware import WhiteNoiseMiddleware
log = logging.getLogger(__name__)
@ipmb
ipmb / Dockerfile
Last active Oct 18, 2020
amazon-ssm-agent Dockerfile
View Dockerfile
FROM golang:1.12-alpine as builder
ARG VERSION=2.3.930.0
RUN set -ex && apk add --no-cache make git gcc libc-dev curl bash && \
curl -sLO https://github.com/aws/amazon-ssm-agent/archive/${VERSION}.tar.gz && \
mkdir -p /go/src/github.com && \
tar xzf ${VERSION}.tar.gz && \
mv amazon-ssm-agent-${VERSION} /go/src/github.com/amazon-ssm-agent && \
cd /go/src/github.com/amazon-ssm-agent && \
echo ${VERSION} > VERSION && \
gofmt -w agent && make checkstyle || ./Tools/bin/goimports -w agent && \
@ipmb
ipmb / cloudfront_signed_storage.py
Created Mar 25, 2020
Django S3 Storage backend to generate signed Cloudfront URLs
View cloudfront_signed_storage.py
"""
S3 Storage served via private Cloudfront URL
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html
https://github.com/boto/boto3/blob/develop/boto3/examples/cloudfront.rst
"""
import datetime
from botocore.signers import CloudFrontSigner
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes, serialization
@ipmb
ipmb / docker-exec-ecs.sh
Last active Oct 29, 2020
docker exec on AWS ECS with SSM
View docker-exec-ecs.sh
#!/bin/bash
# USAGE: CLUSTER=mycluster SERVICE=myservice ./docker-exec-ecs.sh
set -euf -o pipefail
TASK_ARN=$(aws ecs list-tasks --cluster=$CLUSTER --service=$SERVICE \
| jq -r .taskArns[0])
if [ "$TASK_ARN" = "null" ]; then
echo "Could not find any running tasks for $SERVICE on cluster:$CLUSTER."
exit 1
fi
View django_logging.py
import logging.config
from django.utils.log import DEFAULT_LOGGING
# =======
# LOGGING
# =======
LOGGING_CONFIG = None
LOGLEVEL = os.getenv("LOGLEVEL", "info").upper()
@ipmb
ipmb / uwsgi_cors_router.ini
Last active Aug 6, 2019
Add CORS headers for domains matching a regex in uWSGI
View uwsgi_cors_router.ini
# Add CORS header for Origin's which match a regexp
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin#Examples
route-if = regexp:${HTTP_ORIGIN};^.*\.example\.com$ addheader:Access-Control-Allow-Origin: ${HTTP_ORIGIN}
View pyproject.toml
[tool.poetry]
name = "tmp"
version = "0.1.0"
description = ""
authors = ["User <user@example.com>"]
[tool.poetry.dependencies]
python = "^3.7"
requests = "^2.21"
sentry-sdk = "^0.7.11"
@ipmb
ipmb / Dockerfile
Created Apr 4, 2019
Build vmods on Ubuntu from Varnish repo
View Dockerfile
FROM ubuntu:18.04
ARG REPO=varnish60lts
RUN set -ex && \
apt-get update -qq && \
apt-get -yq install curl apt-transport-https build-essential libtool autotools-dev automake gnupg && \
echo "deb https://packagecloud.io/varnishcache/${REPO}/ubuntu/ bionic main" > /etc/apt/sources.list.d/varnish.list && \
curl -L https://packagecloud.io/varnishcache/${REPO}/gpgkey | apt-key add && \
apt-get update -qq && \
apt-get -yq install varnish varnish-dev
View keybase.md

Keybase proof

I hereby claim:

  • I am ipmb on github.
  • I am ipmb (https://keybase.io/ipmb) on keybase.
  • I have a public key ASAhIL1zFberH0RNfVsAfqZOpwcXxLWpcQgGfaSywHmS0wo

To claim this, I am signing this object:

You can’t perform that action at this time.