Skip to content

Instantly share code, notes, and snippets.

View ipmb's full-sized avatar

Peter Baumgartner ipmb

View GitHub Profile
@ipmb
ipmb / transfer.tf
Created December 18, 2020 23:10
AWS Transfer Server with Elastic IP in terraform
variable "TRANSFER_HOST_KEY" {}
locals {
transfer = {
az_count = 2
}
}
resource "aws_eip" "transfer" {
count = local.transfer.az_count
@ipmb
ipmb / check.sh
Last active November 11, 2020 16:35
pipenv version test
$ chmod +x install.sh
$ docker build -t pipenv .
$ docker create --name pipenv pipenv
$ docker cp pipenv:/pipenv .
$ diff pipenv/2018.11.14/Pipfile pipenv/2018.05.18/Pipfile && echo "no difference"
2d1
< name = "pypi"
5,6c4
<
< [dev-packages]
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 April 15, 2020 21:44
Django management command to push whitenoise static files to S3, respecting headers
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 July 12, 2024 07:50
amazon-ssm-agent 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 March 25, 2020 17:09
Django S3 Storage backend to generate signed Cloudfront URLs
"""
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 June 2, 2022 17:30
docker exec on AWS ECS with SSM
#!/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
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 August 6, 2019 17:05
Add CORS headers for domains matching a regex in uWSGI
# 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}
[tool.poetry]
name = "tmp"
version = "0.1.0"
description = ""
authors = ["User <[email protected]>"]
[tool.poetry.dependencies]
python = "^3.7"
requests = "^2.21"
sentry-sdk = "^0.7.11"