AWS CLI Cheatsheet
http://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html https://www.youtube.com/watch?v=_wiGpBQGCjU
#!/bin/bash | |
set -e | |
AWS_FUNCTIONS=$(aws lambda list-functions --query "Functions[].FunctionArn") | |
for func in $AWS_FUNCTIONS | |
do | |
CMD="aws lambda delete-function --function-name $func" | |
echo $CMD | |
$CMD |
# Automated AMI and Snapshot Deletion | |
# | |
# @author Robert Kozora <bobby@kozora.me> | |
# | |
# This script will search for all instances having a tag with "Backup" or "backup" | |
# on it. As soon as we have the instances list, we loop through each instance | |
# and reference the AMIs of that instance. We check that the latest daily backup | |
# succeeded then we store every image that's reached its DeleteOn tag's date for | |
# deletion. We then loop through the AMIs, deregister them and remove all the | |
# snapshots associated with that AMI. |
import boto3 | |
import json | |
client = boto3.client('iam') | |
paginator = client.get_paginator('list_policies') | |
response_iterator = paginator.paginate(Scope='AWS') | |
managed_policies = [] | |
for response in response_iterator: | |
for policy in response['Policies']: |
import boto3 | |
import json | |
client = boto3.client('iam') | |
paginator = client.get_paginator('list_policies') | |
response_iterator = paginator.paginate(Scope='AWS') | |
managed_policies = [] | |
for response in response_iterator: | |
for policy in response['Policies']: |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": [ | |
"autoscaling:Describe*", | |
"cloudformation:DescribeStacks", | |
"cloudformation:DescribeStackEvents", | |
"cloudformation:DescribeStackResources", | |
"cloudformation:GetTemplate", |