Skip to content

Instantly share code, notes, and snippets.

@dmccue
dmccue / enable_s3_to_glacier_lifecycle.sh
Last active September 4, 2018 14:35
Enable S3 to Glacier lifecycle transition on all accounts and buckets
#!/bin/bash
# Created by David McC 2018
# Input: Reads an accounts.txt file containing AccountID, AWS Access Key, AWS Secret Key in comma delimited format
# Description: Applies 0 day S3 lifecycle policy to all buckets in all accounts listed. Transition may take 48 hours.
IFS=$'\n'
export AWS_DEFAULT_OUTPUT="text"
lifecycleJSON=$(cat << EOF
@dmccue
dmccue / fullreadonly-iampolicy.json
Last active December 13, 2016 10:05
Full read-only access role
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "FullPolicy",
"Action": [
"acm:DescribeCertificate",
"acm:ListCertificates",
"acm:GetCertificate",
"appstream:Get*",
#!/bin/bash -xe
# Initiated by:
# bash <(curl -Ls https://gist.github.com/dmccue/ec74e872c6dada7280de0c03656d001a/raw/)
# Description:
# This script will install all necessary software dependencies on a vanilla CentOS7 image in order to enable cfn-* functionality
# Only run on CentOS 7
grep -i '^centos .* 7\.' /etc/redhat-release || exit 0
# Enable epel
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "WordPress Single Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs WordPress with a local MySQL database for storage. It demonstrates using the AWS CloudFormation bootstrap scripts to deploy WordPress.",
"Parameters" : {
"KeyName": {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type": "String",
@dmccue
dmccue / account_report.sh
Created March 10, 2016 22:07
Script to show all resources by account
#!/bin/bash
# Description:
# Script to report which instances belong to which accounts
# Usage:
# Run normally to display all accounts or alternatively specify accountID as argument 1
ACCOUNTS="$(euare-accountlist)\nUnassigned\t000000000000"
ACCOUNT_IDS=$(echo -e "${ACCOUNTS}" | sort | cut -f2)
[ $# -gt 0 ] && ACCOUNT_IDS="${1}"
@dmccue
dmccue / free_ip.py
Last active March 22, 2016 00:19
Script to free floating IP addresses from accounts in eucalyptus
#!/bin/env python
import boto, os, sys
from boto.ec2.regioninfo import RegionInfo
euca_ec2=os.environ['EC2_URL'].replace('http://','').replace('/','').split(':')
euca_ec2_host=euca_ec2[0]
euca_ec2_port=int(euca_ec2[1])
euca_id=os.environ['AWS_ACCESS_KEY']
euca_key=os.environ['AWS_SECRET_KEY']
# clc/ufs/walrus - 10.105.10.51 - odc-f-09
# cc/sc - 10.105.10.70 - odc-f-28
# nc - 10.105.10.73,10.105.10.78 - odc-f-31,odc-f-36
name: hpe-installfest
description: Eucalyptus 4.2 VPC Midonet Server
vars_topology:
# ----------------------------------------------------------------------------------------
# Variables - Configure these to match your environment
# ----------------------------------------------------------------------------------------
name: examplepoc-004
description: Eucalyptus 4.2 VPC MidoNet Cloud
vars_topology:
# Set IPs to match private management network (VAR_PRIVATE_NETWORK)
- &VAR_CLC_IP
#!/usr/bin/env python
import os
import boto
euca_ec2_host="5.10.100.68"
euca_id=os.getenv('AWS_ACCESS_KEY')
euca_key=os.getenv('AWS_SECRET_KEY')
conn = boto.connect_euca(euca_ec2_host, euca_id, euca_key)
print conn.get_all_zones()
#!/usr/bin/env python
import os
import boto
from boto.ec2.regioninfo import RegionInfo
euca_ec2_host="5.10.100.68"
euca_id=os.getenv('AWS_ACCESS_KEY')
euca_key=os.getenv('AWS_SECRET_KEY')
euca_region = RegionInfo(name="eucalyptus", endpoint=euca_ec2_host)
ec2conn = boto.connect_ec2(