Skip to content

Instantly share code, notes, and snippets.

View immanuelpotter's full-sized avatar

Immanuel Potter immanuelpotter

View GitHub Profile
### 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 / 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"
//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 / 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]"
}
@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 "$@"
#!/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 / 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
}
@immanuelpotter
immanuelpotter / .bashrc
Last active October 16, 2019 09:50
bashrc
# .bashrc
# Colorized Prompt
BLACK="\[\033[0;30m\]"
BLUE="\[\033[0;34m\]"
GREEN="\[\033[0;32m\]"
CYAN="\[\033[0;36m\]"
RED="\[\033[0;31m\]"
PURPLE="\[\033[0;35m\]"
BROWN="\[\033[0;33m\]"
#!/bin/bash
NAME_FORMAT="$(date +%d%m%y-azure-%H%M%S)"
# Set these
SSH_KEY_VALUE=""
RESOURCE_GROUP=""
LOCATION="" # Region the instance is in
SEC_GROUP="" # Network security group - using a pre-made here
VNET="" # virtual network to create in