Loop through all EC2 instances (excluding terminated and spot) and enable termination protection
for I in $(aws ec2 describe-instances --query \
'Reservations[].Instances[?(InstanceLifecycle!=`spot` && InstanceState!=`terminated`)].[InstanceId]' \
--output text); do
aws ec2 modify-instance-attribute --disable-api-termination --instance-id $I;
done
- Note: If any links are broken or you know of any more useful guides, please contact me with any suggestions.
- Last Updated: 2020Sep28
- Markdown and white version available here, alternative, click on "Raw".
/* | |
Tired of scrolling to one of the last photos on the page on Instagram? Let your | |
browser do the scrolling for you! | |
31-05-2017 | |
(c) 2017 - Loran Kloeze - [email protected] | |
Usage | |
- Go to https://www.instagram.com/instagram_handle/ (change instagram_handle in i.e. taylorswift) | |
- Open up the console (F12) (Firefox users: type 'allow pasting' if you haven't done so yet) | |
- Select the contents of this complete file and copy/paste it to the console and hit enter |
# Count total EBS based storage in AWS | |
aws ec2 describe-volumes | jq "[.Volumes[].Size] | add" | |
# Count total EBS storage with a tag filter | |
aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add" | |
# Describe instances concisely | |
aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]' | |
# Wait until $instance_id is running and then immediately stop it again | |
aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id | |
# Get 10th instance in the account |
This script can help you find and remove unused AWS snapshots and volumes.
There is hardcoded list of regions that it searches, adjust the value to suit your needs.
Use snapshot.py snapshot-report
to generate report.csv
containing information about all snapshots.
snapshot.py snapshot-cleanup
lets you interactively delete snapshot if it finds it is referencing unexisting resources.
./snapshots.py --help
Sometimes, you need to fake something in Splunk. Might be during development and you don't feel like writing a real search, but you really need a number for a dashboard panel to look right. Maybe you are helping someone with a hairy regex, and you don't want to index data just to test it on your instance. Whatever the reason, here are some searches that have helped me out.
Note that when using these techniques, you are not going through the indexing
Sometimes, you need to fake something in Splunk. Might be during development and you don't feel like writing a real search, but you really need a number for a dashboard panel to look right. Maybe you are helping someone with a hairy regex, and you don't want to index data just to test it on your instance. Whatever the reason, here are some searches that have helped me out.
Note that when using these techniques, you are not going through the indexing
import logging | |
from logging import handlers | |
import traceback | |
import sys | |
import re | |
import os | |
import json | |
import socket # Used for IP Address validation | |
from splunk.appserver.mrsparkle.lib.util import make_splunkhome_path |