Skip to content

Instantly share code, notes, and snippets.

@orlandothoeny
orlandothoeny / migrate-terraform-module-state.sh
Last active March 26, 2024 14:03
Script that moves the Terraform remote state of a root module as a child module into another root module. Blog Post: https://thoeny.dev/how-to-move-terraform-root-module-state-inside-other-root-module
#!/usr/bin/env bash
set -euo pipefail
# Support aborting via SIGINT, without this bash will not exit the for loop until it's finished
trap 'exit 0' INT
# Usage example:
# bash migrate-state.sh '/home/myuser/terraform/destination-module' '/home/myuser/terraform/source-module' 'module.source' 'config/dev_backend.tfvars' 'config/dev_backend.tfvars'
# Arguments:
# $1 - destinationModuleDirectory: The directory in which the module resides where state should be moved to
#!/usr/bin/env bash
# Usage: See help
# $ bash mutagen.sh --help
COMPOSE_PROJECT_NAME=drupal
SYNC_APPDATA_SOURCE=.
SYNC_APPDATA=${COMPOSE_PROJECT_NAME}-appdata
SYNC_APPDATA_DRUPAL=${SYNC_APPDATA}-drupal
# Configuration for local development
version: "3.7"
services:
# MySQL
# -----
db:
image: bitnami/mysql:latest
ports:
- '127.0.0.1:3307:3306'
@orlandothoeny
orlandothoeny / tar-vs-git-benchmark.sh
Created May 6, 2020 09:24
Compares time of cloning a Git repository vs. compressing & extracting it. GIT_REPOSITORY_URL needs to be set.
#!/usr/bin/env bash
set -e
start=$(date +%s)
git clone ${GIT_REPOSITORY_URL} git-repo
end=$(date +%s)
runtime=$((end-start))
printf 'Git clone time: %s seconds\n' "${runtime}"
#!/usr/bin/env bash
set -euo pipefail
# Parameters
# $1: The scheme and host of the site for which the cache should be warmed
warmCache () {
# E.g. https://www.example.com
local schemeAndHost="${1:?'The schemeAndHost parameter is missing'}"