Skip to content

Instantly share code, notes, and snippets.

@nicusX
nicusX / originRequest.js
Created February 24, 2018 11:08
Lambda@Edge A/B testing - single function solution
'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 February 19, 2018 16:16
Lambda@Edge A/B testing - Origin Response
'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 February 19, 2018 16:13
Lambda@Edge A/B testing - Origin Request
'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 February 19, 2018 16:12
Lambda@Edge A/B testing - Viewer Request
'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;
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
}

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:

resource "aws_key_pair" "default_keypair" {
key_name = "my-keypair"
public_key = "ssh-rsa AA....zzz"
}
- hosts: all
gather_facts: false
tasks:
- name: Install Python
raw: "apt-get -y -q install python"
become: true
# 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 }}"
# {{ 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 \