Skip to content

Instantly share code, notes, and snippets.

@kusw3
kusw3 / k8s_dashboard.tf
Created May 3, 2020 21:51
Terraform file using kubernetes provider to deploy metrics-server and kubernetes-dashboard on AWS EKS
# Based on steps for AWS EKS deployment
# https://docs.aws.amazon.com/eks/latest/userguide/dashboard-tutorial.html
# It needs a kubernetes provider to be available
#
####
## Metrics
####
resource "kubernetes_cluster_role" "aggregated-metrics-reader" {
metadata {
@kusw3
kusw3 / data_vpce.tf
Created April 22, 2020 14:25
Sandbox EC2 instance on existing private subnet
data "aws_vpc" "sandbox" {
tags = {
Name = "SandboxVPC"
}
}
data "aws_subnet_ids" "private" {
vpc_id = data.aws_vpc.sandbox.id
filter {
@kusw3
kusw3 / main.tf
Created April 2, 2020 08:54
Bootstrap amzlinux2 script (vars loaded using terraform)
# Load teamplate for provision script of bastion host
data "template_file" "user_data" {
template = file("${path.module}/helpers/provision.sh")
vars = {
TF_tf_zip_url = "https://releases.hashicorp.com/terraform/0.12.23/terraform_0.12.23_linux_amd64.zip"
TF_kc_url = "https://amazon-eks.s3-us-west-2.amazonaws.com/1.15.10/2020-02-22/bin/linux/amd64/kubectl"
TF_iamauth_url = "https://amazon-eks.s3-us-west-2.amazonaws.com/1.15.10/2020-02-22/bin/linux/amd64/aws-iam-authenticator"
TF_eksctl_url = "https://github.com/weaveworks/eksctl/releases/download/latest_release/eksctl_$(uname -s)_amd64.tar.gz"
TF_tz = "Europe/Andorra"
@kusw3
kusw3 / keybase.md
Created March 16, 2020 11:48
keybase.md

Keybase proof

I hereby claim:

  • I am kusw3 on github.
  • I am mrabell (https://keybase.io/mrabell) on keybase.
  • I have a public key ASBXAU3w4wObMjHeXKK6ptMjdSdOiSbDoiJv3zQHZVfrBAo

To claim this, I am signing this object:

#!/bin/bash
# Helper program to get a domain ip into terraform
# Tested on amzlinux2 OS, macosx
# marc@kusw3.com
if [[ $# -ne 1 ]]; then
echo "ERROR: expected 1 argument as domain name"
exit 1;
fi
@kusw3
kusw3 / policy.json
Created October 3, 2019 07:45
Customer: "A part from readonly access to the AWS account, I'll need to be able to create ELB with HTTPS ports using my org user"
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "elasticloadbalancing:*",
"Resource": "*"
},
{
@kusw3
kusw3 / awscli_EC2_oneliners.txt
Last active April 2, 2020 10:06
Useful one liners calling aws api through cli
# Retrive list of running EC2 instances name and private ip address
aws ec2 describe-instances --query 'Reservations[].Instances[?State.Name==`running`].[Tags[?Key==`Name`]|[0].Value,PrivateIpAddress]' --output text
#!/usr/bin/env python
from __future__ import print_function
"""
Shitty script to parse individual files containing a json type salt-ssh output to a yum -q check-update command.
CSV is generated with the id taken from a list and each of packages marked to be udpated
"""
import os