Skip to content

Instantly share code, notes, and snippets.

View huevos-y-bacon's full-sized avatar

Huevos y Bacon huevos-y-bacon

View GitHub Profile
@huevos-y-bacon
huevos-y-bacon / tf_log.sh
Created April 4, 2018 09:23
Terraform debug logging
#!/bin/bash
# Run in temrinal session, before terraform init
# Launch using ". tf_log.sh"
# If NOT running on Mac, comment out last line
export TF_LOG=DEBUG
export TF_LOG_PATH=./TF_LOG.log
touch $TF_LOG_PATH
open /Applications/Utilities/Console.app $TF_LOG_PATH
@huevos-y-bacon
huevos-y-bacon / dd_api.sh
Last active October 20, 2021 14:18
DataDog API (AWS Integration) Interactions using Bash
#!/usr/bin/env bash
# shellcheck disable=SC2034
# API DOCUMENTATION: https://docs.datadoghq.com/api/latest/aws-integration/
# ============================================================
# TO BE REMOVED AND PROVIDED VIA EXPORTS
DD_API_KEY="DATADOG_API_KEY"
DD_APPLICATION_KEY="DATADOG_APPLICATION_KEY"
ACCOUNTID="AWS_ACCOUNT_ID"
@huevos-y-bacon
huevos-y-bacon / bash-array-add-items.sh
Created February 23, 2022 12:08
Bash Arrays - Add Elements
#!/usr/bin/env bash
array=(pluto pippo bob)
echo "array: ${array[*]}"
echo
addlist=(mike john)
echo "add list: ${addlist[*]}"
array+=(${addlist[*]})
echo "${array[@]}"
@huevos-y-bacon
huevos-y-bacon / bash-array-delete-items.sh
Created February 23, 2022 12:09
Bash Arrays - Delete Elements
#!/usr/bin/env bash
# see: https://stackoverflow.com/questions/16860877/remove-an-element-from-a-bash-array
array=(pluto pippo bob john 1 56)
echo "array: ${array[*]}"
echo
delete=(pippo 56)
echo "delete: ${delete[*]}"
for target in "${delete[@]}"; do
for i in "${!array[@]}"; do
@huevos-y-bacon
huevos-y-bacon / nuke-helix-native.sh
Created February 26, 2022 19:23
Simple script to nuke Line 6 Helix Native and all Native user settings for the current user (OS X). See https://line6.com/support/topic/53283-helix-native-code-1116-could-not-decrypt-the-asset/.
#!/bin/bash
[[ "$1" == "yes" ]] || { echo "Specify \"yes\" to nuke Helix Native"; exit 0; }
echo
echo "NUKING HELIX NATIVE!"
echo
FOLDERS=(
"${HOME}/Library/Application Support/Line 6"
@huevos-y-bacon
huevos-y-bacon / aws_wat_workload_arns.sh
Last active March 29, 2022 16:22
Export AWS Well-Architected Tool Workload ARNs to CSV
#!/usr/bin/env bash
# Export AWS Well-Architected Tool Workload ARNs to CSV
usage(){
echo "EXPORT WELL-ARCHITECTED TOOL WORKLOAD ARNs TO CSV
ARGUMENTS:
-d | --days \${number of days} - number of days to include (since last update). Default 3650
-u | --upload | --arns - output APN portal upload-friendly CSV of ARNs only
-h | --help - this output
@huevos-y-bacon
huevos-y-bacon / aws_check_configservice.sh
Last active March 29, 2022 16:22
Check if AWS Config is enabled in all regions
#/bin/bash
# Check if AWS Config is enabled in all regions
for r in $(aws ec2 describe-regions --query 'Regions[].RegionName' --out text); do
aws configservice describe-configuration-recorder-status --region $r --out yaml --query \
'ConfigurationRecordersStatus[].{name:name,recording:recording,lastStatus:lastStatus}';
done
@huevos-y-bacon
huevos-y-bacon / aws_classic_elb_reg.sh
Last active March 29, 2022 16:23
REGISTER OR DEREGISTER INSTANCES WITH/FROM ELB CLASSIC
#!/usr/bin/env bash
# REGISTER OR DEREGISTER INSTANCES WITH/FROM ELB CLASSIC
## SANDBOX/PLAY ACCOUNT
ELBNAME=23feb22
INSTANCES=(
i-0673baad826269229 # Name: dummy1
i-0a72c8136b4ee5042 # Name: dummy2
)
@huevos-y-bacon
huevos-y-bacon / aws_ec2_get_supported_instance_types.sh
Last active March 29, 2022 16:25
Get supported EC2 instance types in the current account and region. If you only need to check for specific types, then specify them in types.txt in the script directory, otherwise it will process all available instance types in the region. Tested on MacOS.
#!/usr/bin/env bash
# Get supported EC2 instance types in the current account and region. If you
# only need to check for specific types, then specify them in types.txt in
# the script directory, otherwise it will process all available instance types
# in the region. Tested on MacOS.
# Prereqs: awscli, jq
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
TMPTYPES=/tmp/types
@huevos-y-bacon
huevos-y-bacon / aws_s3_presigner_md.sh
Last active March 29, 2022 16:25
Create presigned URLs for every object in a given S3 bucket & output to Markdown
#!/bin/bash
# Generate presigned URLs for every object in a given bucket
# Outputs markdown. Preview in IDE and copy to email.
# Prereqs: awscli, jq
EXPIRY=604800 # in SECONDS
BUCKET=$1
OUTFILE=$BUCKET-signed-urls.md