Skip to content

Instantly share code, notes, and snippets.

@koleror
koleror / cleanup_lambda_versions.py
Last active Jun 19, 2020
Cleanup lambda functions versions
View cleanup_lambda_versions.py
import boto3
client = boto3.client('lambda')
def _clean_function(function_data, dry_run, max_versions):
skipped_items = 0
while True: # list_versions_by_function returns up to 50 versions per call
versions = client.list_versions_by_function(
FunctionName=function_data['FunctionArn']
@koleror
koleror / export-simple-membership-users.sql
Created Apr 17, 2020
Export users from Simple WP Membership
View export-simple-membership-users.sql
SELECT member_id, first_name, last_name, member_since, last_accessed, email FROM dbqsv_swpm_members_tbl
LEFT JOIN dbqsv_swpm_membership_tbl
ON ( membership_level = id )
WHERE membership_level=3;
@koleror
koleror / manage-instance.sh
Created Jul 2, 2018
Manage AWS instance from command line
View manage-instance.sh
#!/bin/bash
AWS_PROFILE=<ENTER AWS PROFILE NAME HERE>
AWS_REGION=<ENTER INSTANCE REGION>
AWS_INSTANCE_ID=<ENTER INSTANCE ID HERE>
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
@koleror
koleror / migrate_s3.py
Last active Mar 5, 2018
Migrate AWS S3 bucket content to another bucket, keeping metadatas
View migrate_s3.py
import boto3
old_access_key_id = '***'
old_secret_access_key = '***'
old_bucket_name = '***'
new_access_key_id = '***'
new_secret_access_key = '***'
new_bucket_name = '***'
@koleror
koleror / aws2factor.sh
Last active Jul 2, 2018
Regenerate two factor tokens for AWS and add them to your environment
View aws2factor.sh
#!/bin/bash
command -v aws
if [[ $? != 0 ]]; then
echo "Please install awscli and try again"
return;
fi
set -e