Skip to content

Instantly share code, notes, and snippets.

@lucasproclc
lucasproclc / aws-cleanup.sh
Created September 2, 2021 21:21 — forked from willgarcia/aws-cleanup.sh
Delete all AWS resources (lambdas, cloudfront distribs, ec2, lb, api-gateways, ...)
#!/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
@lucasproclc
lucasproclc / lambdaAMICleanup.py
Created September 29, 2017 04:26 — forked from bkozora/lambdaAMICleanup.py
AWS Lambda Function to Delete AMIs and Snapshots
# Automated AMI and Snapshot Deletion
#
# @author Robert Kozora <[email protected]>
#
# 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.
@lucasproclc
lucasproclc / 01_export_aws_managed_policies.py
Created July 12, 2017 02:30 — forked from gene1wood/aws_iam_managed_policies_2019-02-12.json
Script to export all AWS IAM managed 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']:
@lucasproclc
lucasproclc / 01_export_aws_managed_policies.py
Created July 12, 2017 02:30 — forked from gene1wood/aws_iam_managed_policies_2019-02-12.json
Script to export all AWS IAM managed 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']:
@lucasproclc
lucasproclc / policy.json
Created March 29, 2017 14:52 — forked from ryandotsmith/policy.json
AWS IAM Read Only
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"autoscaling:Describe*",
"cloudformation:DescribeStacks",
"cloudformation:DescribeStackEvents",
"cloudformation:DescribeStackResources",
"cloudformation:GetTemplate",