Skip to content

Instantly share code, notes, and snippets.

View jimvandervoort's full-sized avatar

Jim van der Voort jimvandervoort

View GitHub Profile
@jimvandervoort
jimvandervoort / user-data.sh.tftpl
Created May 16, 2024 10:20
user-data script to install tailscale on AWS EC2 instance and send logs to cloudwatch
#!/bin/bash -ex
#
# Make sure to provide the Terraform template variables between ${}
#
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
# Function to insert a line after a match
insert_after() {
#!/usr/bin/env bash
set -Eeuo pipefail
hosts_file="/etc/hosts"
hosts=(
"www.reddit.com"
"twitter.com"
"www.nrc.nl"
"www.theguardian.com"
@jimvandervoort
jimvandervoort / waitfor.sh
Last active February 16, 2024 09:36
Wait for a Terminal process to complete and send a Telegram message
#!/usr/bin/env bash
set -Eeuo pipefail
function format_time() {
start=$1
end=$2
elapsed=$((end - start))
@jimvandervoort
jimvandervoort / actions-local.sh
Last active May 1, 2023 13:18
Run GitHub Actions script locally
#!/usr/bin/env bash
set -Eeuo pipefail
# Avoid `${{ context }}` expressions in your script directly, pass as env variables instead.
#
# Example:
# - name: Say hi
# env:
# NAME: "${{ github.actor }}"
@jimvandervoort
jimvandervoort / update-gh-actions.sh
Last active March 29, 2023 13:44
Update Actions to latest version
#!/usr/bin/env bash
# Find all github workflows in all repositories under the current directory and update actions to the latest major version.
# Optionally suply workflow file as first argument to update single repo.
#
# Dependabot would be better for this I know. This is just a quick and dirty solution.
set -Eeuo pipefail
update_workflow() {
@jimvandervoort
jimvandervoort / pre-commit.sh
Last active March 29, 2023 13:43
Check Terraform formatting pre-commit hook
#!/usr/bin/env bash
#
# Git hook to enfore formatting Terraform and Terragrunt files
# Quick to setup and free of dependencies (outside of Terraform and Terragrunt)
#
# How to install:
# Assuming you save this script under 'scripts/pre-commit.sh'
# From the root of your repo, run:
# chmod +x scripts/pre-commit.sh