Skip to content

Instantly share code, notes, and snippets.

View immanuelpotter's full-sized avatar

Immanuel Potter immanuelpotter

View GitHub Profile
@immanuelpotter
immanuelpotter / sas-sign.sh
Last active December 15, 2018 14:59
Signing an Azure VHD to share on the marketplace.
#!/bin/bash
RESOURCE_GROUP="$1"
OS_DISK="$2"
err_and_exit(){
if [[ -z "$RESOURCE_GROUP" || -z "$OS_DISK" ]] ; then
echo "Supply the Resource Group as argument 1. Supply the VHD image argument 2, including full path in blob storage."
fi
}
#!/bin/bash
set -ex
#####################################################################################################################
# 1. Change the aws_cmd function to match the naming of your aws credentials
# 2. Check the DATA_PATH var is where your files are ON S3 (or wherever else)
# 3. Make sure you're using the right SSH key
#####################################################################################################################
@immanuelpotter
immanuelpotter / ec2-quick-create-with-storage-existing-sg.sh
Last active July 5, 2021 16:04
quickly launch an amazon linux 1 instance that doesn't need to be in terraform on ec2 for messing around
#!/bin/bash
KEY_NAME=blah
SG_ID=blah
SUBNET_ID=blah
AWS_PROFILE=blah
AWS_REGION=eu-west-2
aws_cmd(){
aws --profile $AWS_PROFILE --region $AWS_REGION "$@"
@immanuelpotter
immanuelpotter / tfonly
Last active August 15, 2020 05:39
If you only want to perform actions on resources in one terraform file, this will do that for you
#!/bin/bash
COMMAND="$1"
TF_FILE="$2"
usage(){
echo "Usage: $0 (plan|apply|destroy) [tf-filename]"
}
//We want to allow the use of two KMS keys from Account A to an IAM User in account B.
//Attach these two SIDs to your user policy in Account B.
{
"Sid": "AllowUseOfKMSKeysFromAccountA",
"Effect": "Allow",
"Action": [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
@immanuelpotter
immanuelpotter / schedule-task.ps1
Last active September 4, 2019 15:31
RAM-free-cloudwatch-custom-metric-powershell
$action = New-ScheduledTaskAction -Execute "powershell" -Argument " we -File C:\Users\Administrator\Documents\WindowsPowerShell\write-ram-cw-custom-metric.ps1 -ExecutionPolicy bypass"
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 1)
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "CustomRAMCloudWatchMetricWrite" -Description "Logging percentage free memory to CloudWatch for this instance"
### Keybase proof
I hereby claim:
* I am immanuelpotter on github.
* I am immanuelpotter (https://keybase.io/immanuelpotter) on keybase.
* I have a public key ASC6arnPIwraZCSzMt9Cvhvw1RPU-M4Jz3EQB_Ry4jGp3go
To claim this, I am signing this object:
@immanuelpotter
immanuelpotter / tpc-h-amazonlinux.sh
Last active February 11, 2020 21:01
Scripting dataset generation using TPC-H toolset in amazon linux, for a record of how it was done
#!/bin/bash
# Ensure an S3 full access role is attached.
# Install TPC-H benchmarking tools on an rpm-based Linux machine, and generate two datasets: 10GB and 40GB of tabular data respectively.
# Create a bucket for storage of the generated data and upload to S3.
# Install tools
sudo yum install -y make git gcc
git clone https://github.com/gregrahn/tpch-kit
@immanuelpotter
immanuelpotter / token-test.py
Last active April 24, 2020 13:43
Testing out PAT tokens can hit required endpoints they need to get to in Azure DevOps.
#!/usr/bin/env python
import requests
import sys
import pprint
import base64
def encode_string(token):
to_encode_string = "Basic:" + token
encoded_str = base64.b64encode(to_encode_string.encode()).decode('utf-8')