This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Delete all snapshots | |
!!!!!!!!!!!!!!!! BE CAREFUL !!!!!!!!!!!!!!!!!!!!!!!!! | |
AWS_DEFAULT_REGION=sa-east-1 AWS_PROFILE=my-profile ./aws-snapshots-delete.py | |
Or to iterate over all regions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" | |
Delete all snapshots | |
!!!!!!!!!!!!!!!! BE CAREFUL !!!!!!!!!!!!!!!!!!!!!!!!! | |
AWS_DEFAULT_REGION=sa-east-1 AWS_PROFILE=my-profile ./aws-snapshots-delete.py | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import click | |
import boto3 | |
import json | |
import prettytable | |
client = boto3.client('marketplace-catalog', region_name='us-east-1') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import boto3 | |
ec2res = boto3.resource('ec2') | |
ec2client = boto3.client('ec2') | |
region_name = ec2client.meta.region_name | |
snapshots = ec2res.snapshots.filter(OwnerIds=['self']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" | |
Get the total amount of GiB snapshots use and calculate the average snapshot size | |
Use eg. with: | |
AWS_DEFAULT_REGION=sa-east-1 AWS_PROFILE=my-profile ./aws-snapshots-size.py | |
""" | |
import boto3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
# this is 2P Ubuntu Pro Xenial | |
SSM_ID=prod-f6ogoaqs7lwre/ubuntu-pro-16.04-lts | |
# get a AMI via SSM from us-east-1 | |
US_EAST_1_AMI=$(aws --region us-east-1 ssm get-parameters --names "/aws/service/marketplace/${SSM_ID}" --query 'Parameters[0].Value' --output text) | |
echo $US_EAST_1_AMI | |
# get the AMI name via describe-images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Author: Thomas Bechtold <[email protected]> | |
import click | |
import boto3 | |
import json | |
import prettytable | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import argparse | |
import configparser | |
import re | |
import jenkins | |
def _config(args): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat aws-images.sh | |
#!/bin/bash | |
OUTFILE=out.txt | |
AWS_REGIONS=(ap-east-1 ap-northeast-1 ap-northeast-2 ap-northeast-3 ap-south-1 ap-southeast-1 ap-southeast-2 af-south-1 ca-central-1 cn-north-1 cn-northwest-1 eu-central-1 eu-north-1 eu-west-1 eu-west-2 eu-west-3 eu-south-1 sa-east-1 me-south-1 us-east-1 us-east-2 us-gov-west-1 us-gov-east-1 us-west-1 us-west-2) | |
for region in ${AWS_REGIONS[@]}; do | |
export AWS_DEFAULT_REGION=$region | |
echo "Getting images for region $region ..." | |
aws ec2 describe-images --owner 099720109477 --query 'Images[?Name!=`null`]|[? (starts_with(Name, `ubuntu/images/`) == `true`) || (starts_with(Name, `ubuntu-minimal/images/`) == `true`) || (starts_with(Name, `ubuntu-eks/`) == `true`)]|[? (contains(Name, `precise`) == `false`) && (contains(Name, `quantal`) == `false`) && (contains(Name, `raring`) == `false`) && (contains(Name, `saucy`) == `false`) && (contains(Name, `trusty`) == `false`) && (contains(Name, `utopic`) == `false`) && (contains(Name, `vivid`) == `false`) && (contain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import argparse | |
import datetime | |
import sys | |
import openstack | |
def _parser(): | |
parser = argparse.ArgumentParser( |
NewerOlder