Skip to content

Instantly share code, notes, and snippets.

View bschaatsbergen's full-sized avatar
:shipit:

Bruno Schaatsbergen bschaatsbergen

:shipit:
View GitHub Profile
@bschaatsbergen
bschaatsbergen / db.tf
Last active March 4, 2025 21:31
Ephemerality in Terraform
provider "aws" {
region = "us-west-2"
}
ephemeral "random_password" "db_password" {
length = 16
}
resource "aws_secretsmanager_secret" "db_password" {
name = "db-password"
@bschaatsbergen
bschaatsbergen / status_test.go
Last active February 15, 2025 14:11
How to mock outbound HTTP traffic in Go using `httptest`
func TestGetStatus_ReturnsActiveStatus(t *testing.T) {
// Arrange a test HTTP server on a dynamically assigned port.
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, `{"results":[{"status":"active"}]}`)
}))
defer ts.Close()
// Creates an HTTP client configured to interact with the test server.
@bschaatsbergen
bschaatsbergen / README.md
Last active October 8, 2024 15:14
Profiling Terraform using pprof and FlameGraph

Build Terraform with some modifications in main.go:

diff --git a/main.go b/main.go
index cce3f5f998..d927fb7e8f 100644
--- a/main.go
+++ b/main.go
@@ -12,6 +12,7 @@ import (
        "os"
        "path/filepath"

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@bschaatsbergen
bschaatsbergen / keybase.md
Created November 16, 2022 08:11
keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@bschaatsbergen
bschaatsbergen / secrets-in-terraform-gcp.md
Last active October 30, 2022 15:56
Secrets in your Terraform code (GCP)

Managing secrets in your Terraform code (the GCP way).

❗ Important note: using this method, the plaintext value of the secret will be persisted into your Terraform state file. This ideally shouldn't pose a problem as long as your Terraform state files are properly secured and encrypted too.

The Google Cloud Terraform provider provides a very clean and intuitive interface in order to store secrets in Git.

Before we can start committing our secrets in a Git repositoriy we first have to create a KMS key ring and a KMS crypto key.

@bschaatsbergen
bschaatsbergen / docker-compose.yml
Created May 14, 2021 22:34
Dockerized Primary/Replica Redis
version: "3.9"
services:
redis-primary:
container_name: redis-primary
image: redis:latest
command: redis-server --port 6379
ports:
- "6379:6379"
redis-replica:
container_name: redis-replica
@bschaatsbergen
bschaatsbergen / docker-compose.yml
Created May 10, 2021 20:20
Dockerized TeamCity cluster
version: '3.1'
# ./buildserver_pgdata - Postgres DB data
# ./data - TeamCity data directory
# ./teamcity-server-logs1 - logs of primary TeamCity server
# ./teamcity-server-logs2 - logs of secondary TeamCity server (running-builds node)
# ./teamcity-server-logs3 - logs of read-only TeamCity server (secondary node)
# ./teamcity-agent-conf1 - conf directory for the build agent
# ./teamcity-agent-conf2 - conf directory for the build agent
# ./teamcity-agent-conf3 - conf directory for the build agent
@bschaatsbergen
bschaatsbergen / docker-compose.yml
Last active February 26, 2025 15:33
multi-node elasticsearch cluster
version: '2.2'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
container_name: es01
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es02,es03
- cluster.initial_master_nodes=es01,es02,es03