Skip to content

Instantly share code, notes, and snippets.

@whereisaaron
whereisaaron / get-aws-eks-node-ami-versions.sh
Created November 13, 2022 04:11
Get the versions names for AWS EKS Kubernetes node AMIs as listed in releases at https://github.com/awslabs/amazon-eks-ami/releases
#!/bin/bash
set -e -u -o pipefail
#
# Get the versions names for node AMIs as listed in AMI releases
# https://github.com/awslabs/amazon-eks-ami/releases
#
: ${CLUSTER:=${1?"Must specify cluster name"}}
@whereisaaron
whereisaaron / CleanUpOrphanedSubplansAndLogs.sql
Created November 12, 2022 11:27
Clean up orphaned SQL Server Maintenance Plan subplans and their logs, use this if you get a conflict error deleting a job
--
-- Clean up orphaned Maintenance Plan subplans and their logs
-- Use this if you get a conflict error deleting a job
--
use [msdb]
GO
delete from msdb..sysmaintplan_log
where plan_id not in (
@whereisaaron
whereisaaron / create-dummy-files.sh
Created October 31, 2022 17:52
Create a collection of dummy files to use up space
#!/bin/bash -e
START=${1:-1}
END=${2:-10}
for i in $(seq ${START} ${END}); do
filename=$(printf 'dummy-10GiB-%03d.bin' $i)
if [[ -f ${filename} ]]; then
echo "Dummy file ${filename} already exists"
else
@whereisaaron
whereisaaron / Dockerfile
Last active September 12, 2023 14:57
Support for automatic restarting for Apache after mod_md renews a certificate and invokes `MDMessageCmd renewed` command
#--------------------------------------
# Build md_event command
#--------------------------------------
FROM gcc:bullseye as build
COPY ./md_event.c .
RUN gcc md_event.c -o md_event
#--------------------------------------
# Apache container
#--------------------------------------
@whereisaaron
whereisaaron / create-self-signed-cert.sh
Created August 4, 2022 09:12
Create a self-signed certificate using openssl to bootstrap a server
#!/bin/bash
set -eu
#
# Create a self-signed certificate to bootstrap a server
# Ref: https://devopscube.com/create-self-signed-certificates-openssl/
#
if [ "$#" -ne 1 ]
then
@whereisaaron
whereisaaron / snippet.cs
Created August 3, 2022 11:35
Route two different AWS ECS/Fargate container ports (80 & 443) via two different Network Load Balancer Target Groups with AWS CDKv2
var myService = new FargateService(this, "MyService", new FargateServiceProps {
Cluster = myCluster,
DesiredCount = 2,
AssignPublicIp = true,
TaskDefinition = myTaskDef,
EnableExecuteCommand = true,
});
targetGroupPort80.AddTarget(new [] {
service.LoadBalancerTarget(new LoadBalancerTargetOptions {
@whereisaaron
whereisaaron / openvpn-simple-password-auth.sh
Created April 10, 2022 08:49
Simple external script to use with OpenVPN or similar for username and password authentication (auth-user-pass-verify)
#!/bin/bash
#
# Read username and password from the supplied filename
#
readarray -t lines < $1
username=${lines[0]}
password=${lines[1]}
#
@whereisaaron
whereisaaron / unzip-recursive.ps1
Created March 27, 2022 07:29
Unzip a tree of folders containing ZIP files, requires PowerShell and 7z
Get-ChildItem –Path "C:\temp" -Recurse |
Where-Object -Property Extension -EQ '.zip' |
Foreach-Object {
Write-Output $_.FullName
$command = "7z x ""$($_.FullName)"" -o""$($_.Directory)"" -aos -bso0 -bsp2"
Write-Output $command
@whereisaaron
whereisaaron / json-to-helm-values.sh
Created September 10, 2020 06:20
Convert JSON object to YAML values for a helm chart
#!/bin/bash
json_to_values() {
json=$1
echo "env:"
jq -r 'to_entries | .[] | " - name: \(.key)\n value: '"'"'\(.value)'"'"'"' <<<$json
}
read -r -d '' foo << END
{
@whereisaaron
whereisaaron / aws-eks-vpc-3az.yaml
Last active February 6, 2019 05:52
CloudFormation template to create a VPC with public and private subnets and NAT, suitable for high availability AWS EKS Kubernetes clusters
---
# VPC template for housing EKS clusters
# Based on VPC template by Levon Becker v20161125-1430
# https://github.com/stelligent/cloudformation_templates
#
AWSTemplateFormatVersion: '2010-09-09'
Description: Create a VPC with per-AZ NAT and public/private subnets
Parameters:
# Cluster Names
ClusterName1: