Skip to content

Instantly share code, notes, and snippets.

@nicusX
nicusX / originRequest.js
Created Feb 24, 2018
Lambda@Edge A/B testing - single function solution
View originRequest.js
'use strict';
const sourceCoookie = 'X-Source';
const sourceMain = 'main';
const sourceExperiment = 'experiment';
const experimentTraffic = 0.5;
const experimentBucketEndpoint = 'my-experiment.s3.amazonaws.com';
const experimentBucketRegion = 'eu-west-1';
@nicusX
nicusX / originResponse.js
Created Feb 19, 2018
Lambda@Edge A/B testing - Origin Response
View originResponse.js
'use strict';
const sourceCoookie = 'X-Source';
const sourceMain = 'main';
const sourceExperiment = 'experiment';
const cookiePath = '/';
// Origin Response handler
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
@nicusX
nicusX / originRequest.js
Created Feb 19, 2018
Lambda@Edge A/B testing - Origin Request
View originRequest.js
'use strict';
const sourceCoookie = 'X-Source';
const sourceMain = 'main';
const sourceExperiment = 'experiment';
const experimentBucketName = 'my-experiment.s3.amazonaws.com';
const experimentBucketRegion = 'eu-west-1';
// Origin Request handler
exports.handler = (event, context, callback) => {
@nicusX
nicusX / viewerRequest.js
Last active Feb 19, 2018
Lambda@Edge A/B testing - Viewer Request
View viewerRequest.js
'use strict';
const sourceCoookie = 'X-Source';
const sourceMain = 'main';
const sourceExperiment = 'experiment';
const experimentTraffic = 0.5;
// Viewer request handler
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
View k8snthw-iam.tf
resource "aws_iam_role" "kubernetes" {
name = "kubernetes"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [ { "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com" }, "Action": "sts:AssumeRole" } ]
}
EOF
}
View keybase.md

Keybase proof

I hereby claim:

  • I am nicusX on github.
  • I am nicus (https://keybase.io/nicus) on keybase.
  • I have a public key whose fingerprint is DDAE E90D B270 D52C 7D70 CBD6 01D7 58A7 D46D 6B5B

To claim this, I am signing this object:

View k8snthw-keypair.tf
resource "aws_key_pair" "default_keypair" {
key_name = "my-keypair"
public_key = "ssh-rsa AA....zzz"
}
View k8snthw-infra-bootstrap.yaml
- hosts: all
gather_facts: false
tasks:
- name: Install Python
raw: "apt-get -y -q install python"
become: true
View k8snthw-kubectl.yaml
# Expects `kubernetes_api_endpoint` as `--extra-vars "kubernetes_api_endpoint=xxxx"`
- hosts: 127.0.0.1
connection: local
tasks:
- name: Set kubectl endpoint
shell: "kubectl config set-cluster {{ cluster_name }} --certificate-authority={{ playbook_dir }}/../cert/ca.pem --embed-certs=true --server=https://{{ kubernetes_api_endpoint }}:6443"
- name: Set kubectl credentials
shell: "kubectl config set-credentials {{ user }} --token {{ token }}"
View k8snthw-etcd.service.j2
# {{ ansible_managed }}
[Unit]
Description=etcd
Documentation=https://github.com/coreos
[Service]
ExecStart=/usr/bin/etcd --name {{ inventory_hostname }} \
--cert-file=/etc/etcd/kubernetes.pem \
--key-file=/etc/etcd/kubernetes-key.pem \
--peer-cert-file=/etc/etcd/kubernetes.pem \