Skip to content

Instantly share code, notes, and snippets.

View mvanholsteijn's full-sized avatar

Mark van Holsteijn mvanholsteijn

View GitHub Profile
#!/bin/bash
#
# Installs and Configures the AWS cloudwatch agent, and sets the default log group name and region
#
#
# You need to add the following policy statement to the machine's IAM role.
#
# {
# "Effect": "Allow",
# "Action": [
@mvanholsteijn
mvanholsteijn / get-auth0-public-rsa-key
Created December 18, 2017 13:47
Retrieve the public RSA key for the Auth0 tenant in PEM format
AUTH0_DOMAIN=mvanholsteijn.eu.auth0.com
curl -sS https://$AUTH0_DOMAIN/pem | \
openssl x509 -pubkey -noout
@mvanholsteijn
mvanholsteijn / get-auth0-public-rsa-key-as-json
Last active December 18, 2017 13:49
Retrieve the public RSA key for the Auth0 tenant in PEM format as JSON String
AUTH0_DOMAIN=mvanholsteijn.eu.auth0.com
curl -sS https://$AUTH0_DOMAIN/pem | \
openssl x509 -pubkey -noout | \
tr -d '\r' | \
tr '\n' '|' | \
sed -e 's/|/\\n/g' | \
sed -e 's/^/"/' -e 's/$/"/'
@mvanholsteijn
mvanholsteijn / report-cloudformation-stack-errors
Created February 8, 2018 12:57
Reports the failed resources in the last AWS CloudFormation stack operations.
#!/usr/bin/env python
#
# reports errors on the last stack operations
#
import sys
import boto3
def report_errors(stackname):
cfn = boto3.client('cloudformation')
@mvanholsteijn
mvanholsteijn / gcp-instance-delete-external-ip
Created October 13, 2018 13:33
gcloud command deleting an external ip address from an GCP instance
#!/bin/bash
gcloud compute instances delete-access-config $INSTANCE --access-config-name external-nat

Keybase proof

I hereby claim:

  • I am mvanholsteijn on github.
  • I am mvanholsteijn (https://keybase.io/mvanholsteijn) on keybase.
  • I have a public key ASC8m3WQn3rAaN6rL70h8G5tzhZXjiRrNBqS3heiR9KVego

To claim this, I am signing this object:

@mvanholsteijn
mvanholsteijn / add-auth0-jwt-plugin
Created December 7, 2017 16:47
Add a Auth0 JWT plugin on an Kong API Gateway API
#!/bin/bash
DOMAIN=${1:-mvanholsteijn.eu.auth0.com}
KONG_API=http://localhost:8001
PUBLIC_KEY=$(curl -sS https://${DOMAIN}/pem | openssl x509 -pubkey -noout)
[[ -z $PUBLIC_KEY ]] && echo "ERROR: could not retrieve public key of $PUBLIC_KEY" && exit 1
# add user
curl -sS -i -X POST $KONG_API/consumers --data username=$DOMAIN
@mvanholsteijn
mvanholsteijn / generate-aws-directory-service-awsconfig-domain-create-ssm-document-command.sh
Created January 28, 2020 06:16
generates the SSM document required for automatic AD domain join on AWS
#!/bin/bash
aws ds describe-directories --query 'DirectoryDescriptions[*].{
"schemaVersion": `"1.0"`,
"description": join(``, [`Automatic AD domain-join configuration for `, Name, `.`]),
"runtimeConfig": {
"aws:domainJoin": {
"properties": {
"directoryId": DirectoryId,
"directoryName": Name,
"dnsIpAddresses": OwnerDirectoryDescription.DnsIpAddrs
terraform {
required_version = ">= 0.12"
}
variable project {
type = string
}
provider "google" {
project = var.project
@mvanholsteijn
mvanholsteijn / instances.go
Last active May 6, 2020 18:07
list all gce instances authenticating with the current gcloud configuration
package main
import (
"context"
"flag"
"fmt"
"github.com/binxio/gcloudconfig"
"golang.org/x/oauth2/google"
"google.golang.org/api/compute/v1"
"google.golang.org/api/option"