Skip to content

Instantly share code, notes, and snippets.

View stafot's full-sized avatar
🐬

Stavros Foteinopoulos stafot

🐬
View GitHub Profile
@stafot
stafot / k8s-patch.go
Created December 28, 2018 15:16 — forked from dwmkerr/k8s-patch.go
Example showing how to patch Kubernetes resources in Golang. Companion to the article 'https://dwmkerr.com/patching-kubernetes-resources-in-golang/'.
// Example showing how to patch kubernetes resources.
// This is the companion to my article 'Patching Kubernetes Resources in Golang':
// https://dwmkerr.com/patching-kubernetes-resources-in-golang/
package main
import (
"encoding/json"
"fmt"
types "k8s.io/apimachinery/pkg/types"
@stafot
stafot / gpr.sh
Created December 28, 2018 15:18 — forked from dwmkerr/gpr.sh
A shell command to push and open a pull request. Tested on OSX/Ubuntu. No dependencies.
#!/usr/bin/env bash
# gpr - push the current branch to origin and attempt to open the Create Pull
# Request or Create Merge Request page if available.
#
# Inspired by: https://gist.github.com/tobiasbueschel/ba385f25432c6b75f63f31eb2edf77b5
# How to get the current branch: https://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch
# How to open the browser: https://stackoverflow.com/questions/3124556/clean-way-to-launch-the-web-browser-from-shell-script
# Colour constants for nicer output.
GREEN='\033[0;32m'
@stafot
stafot / open-pr
Created February 21, 2019 19:48 — forked from garno/open-pr
Small bash script to automatically open Pull Request page with branches correctly selected
#!/bin/sh
# Retrieve branch name
branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
# Retrieve destination branch
destination_branch=${branch%--*}
# Determine the default origin branch
if [[ $branch == $destination_branch ]]; then
@stafot
stafot / README.md
Created May 24, 2019 14:16 — forked from iMilnb/README.md
AWS Terraform configuration: Stream CloudWatch Logs to ElasticSearch

Rationale

This snippet is a sample showing how to implement CloudWatch Logs streaming to ElasticSearch using terraform. I wrote this gist because I didn't found a clear, end-to-end example on how to achieve this task. In particular, I understood the resource "aws_lambda_permission" "cloudwatch_allow" part by reading a couple of bug reports plus this stackoverflow post.

The js file is actually the Lambda function automatically created by AWS when creating this pipeline through the web console. I only added a endpoint variable handling so it is configurable from terraform.