Skip to content

Instantly share code, notes, and snippets.

View mvanholsteijn's full-sized avatar

Mark van Holsteijn mvanholsteijn

View GitHub Profile
@mvanholsteijn
mvanholsteijn / test.js
Last active February 16, 2023 12:38
simple k6 performance test script for privatebin installations
import http from 'k6/http';
import {
sleep,
check
} from 'k6';
import {Trend} from 'k6/metrics';
import privatebin from 'k6/x/privatebin';
let createMetric = new Trend('01 - create-paste');
let getMetric = new Trend('02 - get-paste');
@mvanholsteijn
mvanholsteijn / locustfile.py
Created June 11, 2021 21:19
A simple locust performance test script to load test a privatebin installation
from locust import SequentialTaskSet, HttpUser, between, task
from locust.contrib.fasthttp import FastHttpUser
from pbincli.api import PrivateBin
from pbincli.format import Paste
class SequenceOfTasks(SequentialTaskSet):
def on_start(self):
self.payload = "hello world"
self.url = None
@mvanholsteijn
mvanholsteijn / privatebin.tf
Created May 24, 2021 13:08
A Cloud Run deployment of PrivateBin
variable "region" {
type = string
default = "europe-west4"
}
variable "project" {
type = string
}
variable "image" {
@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