What this will cover
- Host a static website at S3
- Redirect
www.website.com
towebsite.com
- Website can be an SPA (requiring all requests to return
index.html
) - Free AWS SSL certs
- Deployment with CDN invalidation
def get_or_create(session, model, defaults=None, **kwargs): | |
""" | |
Get or create a model instance while preserving integrity. | |
""" | |
try: | |
return session.query(model).filter_by(**kwargs).one(), False | |
except NoResultFound: | |
if defaults is not None: | |
kwargs.update(defaults) |
[Linux Container Internals 2.0](https://docs.google.com/presentation/d/1S-JqLQ4jatHwEBRUQRiA5WOuCwpTUnxl2d1qRUoTz5g/edit#slide=id.g3e1a17e39e_2_41) |
aws> ec2 describe-vpcs | |
aws> ec2 create-vpc --cidr-block 10.0.0.0/16 | |
aws> ec2 create-tags --resources vpc-f0bff594 --tags Key=Name,Value=sample-vpc | |
aws> ec2 describe-vpcs | |
aws> ec2 describe-internet-gateways | |
aws> ec2 create-internet-gateway | |
aws> ec2 create-tags --resources igw-6992410d --tags Key=Name,Value=sample-vpc-igw | |
aws> ec2 attach-internet-gateway --vpc-id vpc-f0bff594 --internet-gateway-id igw-6992410d | |
aws> ec2 describe-internet-gateways | |
aws> ec2 describe-subnets --query 'Subnets[?VpcId==`vpc-f0bff594`]' |
ifconfig (or ip link, ip addr) - for obtaining information about network interfaces | |
ping | |
for validating, if target host is accessible from my machine. | |
ping is also could be used for basic DNS diagnostics - we could ping host by IP-address or by its hostname and then decide if DNS works at all. And then traceroute or tracepath or mtr to look what's going on on the way there. | |
dig |
You can pull a capture from S3 into #Wireshark using the AWS CLI: | |
aws s3 cp s3://my-bucket/odd-http.pcap - | wireshark -k -i - |
https://serverfault.com/questions/791715/using-environment-variables-in-kubernetes-deployment-spec | |
A much easier/cleaner solution: envsubst | |
In deploy.yml: | |
LoadbalancerIP: $LBIP | |
Then just create your env var and run kubectl like this: | |
export LBIP="1.2.3.4" |
#!/bin/sh | |
# Use AWS CLI to get the most recent version of an AMI that | |
# matches certain criteria. Has obvious uses. Made possible via | |
# --query, --output text, and the fact that RFC3339 datetime | |
# fields are easily sortable. | |
export AWS_DEFAULT_REGION=us-east-1 | |
aws ec2 describe-images \ |
var fs = require('fs'); | |
function Reader() { | |
this.content = null; | |
} | |
Reader.prototype.getContent = function() { | |
if (this.content === null) { | |
return new Promise((resolve, reject) => { | |
console.log('new promise'); |
#!/usr/bin/env python | |
from applicationinsights import TelemetryClient | |
import subprocess | |
import sys | |
import socket | |
hostname = socket.gethostname() | |
telemetry_id = sys.argv[1] | |
tc = TelemetryClient(telemetry_id) |