Skip to content

Instantly share code, notes, and snippets.

Edge CloudFront CLI

Configure and activate an AWS CLI Profile

Configure a new edge profile with your addon AWS credentials:

$ heroku config --app edgeapp
EDGE_AWS_ACCESS_KEY_ID:     AKIA...
EDGE_AWS_SECRET_ACCESS_KEY: JRHH...
@nzoschke
nzoschke / bios.sh
Last active January 10, 2018 15:48
#!/bin/bash
set -ex
export GIT_DIR=src/$PKG/.git
run -s "Cloning" git clone $URL --branch $REF --single-branch src/$PKG && git reset --hard $SHA
PKGS=$(go list $PKG/...)
run -s "Linting" golint -set_exit_status $PKGS
run -s "Vetting" go vet -x $PKGS
run -s "Building" go build -v $PKGS

First, check out Discourse and patch it for Heroku. To get the first push to build we need to run migrations before asset precompilation. To get the web dyno to start, we need to configure Puma to stay in the foreground.

## Check out Discourse

$ git clone https://github.com/discourse/discourse.git
$ cd discourse

## Patch Discourse for Heroku
@nzoschke
nzoschke / EFS.sh
Last active December 15, 2016 23:02
root@642dc10588ea:/var/www/html# find . -type f | wc -l
11035
root@642dc10588ea:/var/www/html# tar cfv /tmp/oc.tar --one-file-system -C /usr/src/owncloud .
root@642dc10588ea:/var/www/html# du -h /tmp/oc.tar
98M /tmp/oc.tar
root@642dc10588ea:/var/www/html# time tar cfv - --one-file-system -C /usr/src/owncloud . | tar xf - -k
real 0m36.628s
@nzoschke
nzoschke / Dockerfile
Created June 12, 2016 20:08
Modern Ruby / Rails Dockerfile
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get -yy install build-essential ruby-dev
RUN apt-get -yy install libmysqld-dev libpq-dev libsqlite3-dev
RUN apt-get -yy install nginx nodejs
WORKDIR /app
ENV PORT 5000
@nzoschke
nzoschke / lambda-canary.js
Last active March 5, 2016 23:46
Lambda Canary
var http = require('http');
exports.handler = function(event, context) {
// return success before 5m
console.log("setTimeout start");
setTimeout(function(){
console.log('setTimeout 290s finish');
context.succeed('setTimeout 290s finish');
}, 290000);
# Save the AWS Convox API environment to .env
$ convox ps --app convox
ID NAME RELEASE SIZE STARTED COMMAND
7e41311911f7 registry 20160127162722 256 3 hours ago /docker-entrypoint.sh
7a3ef788202b web
$ convox exec --app convox 7a3ef788202b env > .env
# Start a Docker Machine environment
@nzoschke
nzoschke / create-convox-support.sh
Last active October 24, 2017 19:40
Creating a convox-support IAM User and Login
$ aws iam create-user --user-name convox-support
{
"User": {
"UserName": "convox-support",
"Path": "/",
"CreateDate": "2015-08-09T15:16:09.027Z",
"UserId": "AIDAIEXRZQYWRHLT6NX6O",
"Arn": "arn:aws:iam::901416387788:user/convox-support"
}
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg id="svg" width="1080px" height="760px" viewBox="0 0 1080 760" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>assembly 2015</title>
<style>
.dark #background {
fill:black;
}
text {
fill: #ffffff;
}

Most web traffic should be available over HTTPS. AWS makes this easy with Elastic Load Balancers (ELBs). When configured with an SSL certificate, an ELB will perform SSL termination and forward the traffic onto our group of non-encrypted web server instances.

Using an ELB is advantageous to offload many responsibilities to Amazon:

Maintaining uptime for the primary service DNS name Balancing traffic to one or more instances Re-balancing traffic when instances are added, removed, or become unhealthy Storing and applying your mission-critical secret SSL certificate Configuring critical aspects of HTTP like what SSL protocols, cypher and options are available and permitted