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 / 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 / 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 / copy-ssm-parameters
Created February 14, 2018 10:47
script to copy all SSM parameter store parameters to disk
#!/usr/bin/env python
#
# copy all SSM parameter store parameters to disk
#
import os, sys, argparse, boto3
parser = argparse.ArgumentParser(description='copy all parameter values to local')
parser.add_argument("--path", dest="path", required=True,
help="to copy the keys from", metavar="STRING")
parser.add_argument("--directory", dest="directory", required=True,
@mvanholsteijn
mvanholsteijn / copy route53 hosted zone
Last active March 29, 2021 12:08
a short shell script to copy the contents from one Route53 hosted zone to the other
#!/bin/bash
aws route53 list-resource-record-sets \
--hosted-zone ${SOURCE_HOSTED_ZONE_ID} \
--query '{Changes: ResourceRecordSets[?Type != `NS` && Type != `SOA`].{"Action": `UPSERT`, "ResourceRecordSet": @ }}' > changeset.json
aws route53 change-resource-record-sets \
--hosted-zone ${TARGET_HOSTED_ZONE_ID} \
--change-batch "$(<changeset.json)"
@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:

AWSTemplateFormatVersion: '2010-09-09'
Description: AWS Backup daily CloudFormation configuration
Resources:
BackupPlan:
Type: AWS::Backup::BackupPlan
Properties:
BackupPlan:
BackupPlanName: default
BackupPlanRule:
- RuleName: daily-backups