Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)
First one found from of
| #!/usr/bin/env ruby | |
| require 'optparse' | |
| require 'ostruct' | |
| require 'aws-sdk' | |
| require 'base64' | |
| require 'openssl' | |
| class Passworder | |
| def initialize(args) | |
| parse_opts(args) |
| #!/usr/bin/env ruby | |
| # Implement CIS Benchmarks for AWS Section 3.x | |
| # Details on each benchmark from https://benchmarks.cisecurity.org/downloads/show-single/?file=awsfoundations.100 | |
| # name should be in camelcase since we'll use it for filter and alarm names | |
| filters = [ | |
| { | |
| benchmark: '3.1', |
| #! /usr/bin/python | |
| instdata_host = "169.254.169.254" | |
| instdata_ver = "2009-04-04" | |
| instdata_url = "http://%s/%s" % (instdata_host, instdata_ver) | |
| __doc__ = """ | |
| Query and display EC2 metadata. | |
| If no options are provided, all options will be displayed |
| #!/usr/bin/python | |
| # Search for instances based on name tag | |
| # Usage ./instance_search.py webserver | |
| # Prints a hostfile style format | |
| import boto.ec2 | |
| import sys | |
| conn=boto.ec2.connect_to_region('ap-southeast-2') | |
| reservations = conn.get_all_reservations(filters={'instance-state-name': 'running', 'tag-key': 'Name'}) | |
| for res in reservations: | |
| for inst in res.instances: |
Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)
First one found from of
| # Get a specific stack output where stack name contains | |
| aws cloudformation --region ap-southeast-2 --profile myprofile describe-stacks --query 'Stacks[*]|[?contains(StackName, `myapp`) == `true`]|[].Outputs[?OutputKey==`DeploymentDns`].OutputValue' --output text | |
| # Security groups that contain 0.0.0.0/0 rules | |
| aws ec2 describe-security-groups --filters Name=ip-permission.cidr,Values=0.0.0.0/0 --output=text | grep SECURITYGROUPS | |
| # Security groups for ElasticSearch | |
| aws ec2 describe-security-groups --filters Name=ip-permission.from-port,Values=9200 --output=text | grep SECURITYGROUPS |
| wget http://stedolan.github.io/jq/download/linux64/jq | |
| aws ec2 describe-instances --filters "Name=tag:Name,Values=$NAME" \ | |
| "Name=instance-state-name,Values=running" \ | |
| | jq -r \ | |
| ".Reservations[] | .Instances[] | .InstanceId" \ | |
| aws ec2 describe-volumes --filters \ | |
| "Name=status,Values=available" \ | |
| | jq -r ".Volumes[] | .VolumeId" \ |
Related Setup: https://gist.github.com/hofmannsven/6814278
Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
| #!/usr/bin/env bash | |
| set -eu | |
| # PATH TO YOUR HOSTS FILE | |
| : ${ETC_HOSTS="/etc/hosts"} | |
| # DEFAULT IP FOR HOSTNAME | |
| DEFAULT_IP="127.0.0.1" |
| #!/bin/sh | |
| # PATH TO YOUR HOSTS FILE | |
| ETC_HOSTS=/etc/hosts | |
| # DEFAULT IP FOR HOSTNAME | |
| IP="127.0.0.1" | |
| # Hostname to add/remove. | |
| HOSTNAME=$1 |