Skip to content

Instantly share code, notes, and snippets.

View mvanholsteijn's full-sized avatar

Mark van Holsteijn mvanholsteijn

View GitHub Profile
@mvanholsteijn
mvanholsteijn / generate-githuber-md-prism-definition
Created May 7, 2021 14:35
generates the PHP prism variable definitions for the WP githuber MD plugin
#!/bin/bash
set -e -u -o pipefail
download_components_json() {
curl -sS -L -o $2 $1
}
generate_prism_codes() {
@mvanholsteijn
mvanholsteijn / deploy.py
Created January 19, 2021 18:41
dummy deploy script demonstrating python script exec
#!/usr/bin/env python3
import sys
if __name__ == "__main__":
print(" ".join(sys.argv))
@mvanholsteijn
mvanholsteijn / main.py
Last active January 19, 2021 18:40
sample google cloud function exec'ing a python program
import sys
import os
from flask import make_response
import logging as log
import subprocess
def entry(request):
out = ""
err = ""
@mvanholsteijn
mvanholsteijn / generate_gcp_service_dependencies.py
Last active October 3, 2020 13:31
generates a dot file from to Google Cloud Platform service dependencies
""""
generates a dot file from the output of `google services list --available --format json`.
it only draws services that are referenced as a dependency.
"""
import sys
from re import sub
import json
from typing import Dict, List
ServiceDictionary = Dict[str, "Service"]

A generated secret version resource.

This will generate a secret and store the value directly in the Google Secret manager secret, to avoid the secret appearing in clear text in the terraform source or the terraform state file.

given secrets should be stored using the google_kms_secret and the google_secret_manager_secret_version.

When the secret version is updated outside the scope of the terraform template, the resource will return the latest version.

@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"
terraform {
required_version = ">= 0.12"
}
variable project {
type = string
}
provider "google" {
project = var.project
@mvanholsteijn
mvanholsteijn / update-all-route53-domains-contacts.py
Created February 10, 2020 14:48
update the contacts of all route53 registered domains
import boto3
import json
contact = {
"FirstName": "Mark",
"LastName": "van Holsteijn",
"ContactType": "COMPANY",
"AddressLine1": "Laapersveld 27",
"City": "Hilversum",
"CountryCode": "NL",
@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
AWSTemplateFormatVersion: '2010-09-09'
Description: AWS Backup daily CloudFormation configuration
Resources:
BackupPlan:
Type: AWS::Backup::BackupPlan
Properties:
BackupPlan:
BackupPlanName: default
BackupPlanRule:
- RuleName: daily-backups