Skip to content

Instantly share code, notes, and snippets.

View nmagee's full-sized avatar

Neal Magee nmagee

View GitHub Profile
@nmagee
nmagee / boto3-error-example
Last active July 18, 2017 14:08
A simple example of how to handle boto3 errors using botocore
import boto3
import botocore
import errorsns # A custom SNS handler
def check_queue():
client = boto3.client('sqs', region_name='us-east-1')
req = client.receive_message(
QueueUrl='https://sqs.us-east-1.amazonaws.com/123456789012/my-queue',
MessageAttributeNames=[
'JobID',
{
"success": {
"total": 1
},
"contents": {
"quotes": [
{
"quote": "When it comes to winning, you need the skill and the will.",
"length": "58",
"author": "Frank Tyger",
@nmagee
nmagee / sync-up.sh
Created November 6, 2017 19:19
Synchronize a local folder up to an S3 bucket
#!/bin/bash
bucket='YOUR-BUCKET-NAME'
dir='/your/local/directory/'
aws s3 sync $dir s3://$bucket
# If you want the bucket to match the local directory exactly, including any files
# you may delete at a later point, add --delete after sync
#
@nmagee
nmagee / sync-down.sh
Created November 6, 2017 19:21
Synchronize an S3 bucket with a local folder
#!/bin/bash
bucket='YOUR-BUCKET-NAME'
dir='/your/local/directory/'
aws s3 sync s3://$bucket/ $dir
# If you want the bucket to match the local directory exactly, including any files
# you may delete at a later point, add --delete after sync
#
@nmagee
nmagee / start-instances.sh
Created November 7, 2017 16:37
Start one or more EC2 instances. Run this on your local workstation.
#!/bin/bash
# This can be one or more EC2 instance IDs, separated by a space. No commas.
instanceIds=''
aws ec2 start-instances --instance-ids $instanceIds
@nmagee
nmagee / stop-instances.sh
Created November 7, 2017 16:37
Stop one or more EC2 instances. Run this on your local workstation.
#!/bin/bash
# This can be one or more EC2 instance IDs, separated by a space. No commas.
instanceIds=''
aws ec2 stop-instances --instance-ids $instanceIds
#!/bin/bash
# Transfers a directory, recurisvely.
# Note the optional --encrypt flag.
set -e
globus=`which globus`
srce=c4d80096-7612-11e7-8b5e-22000b9923ef
dest=c4d80096-7612-11e7-8b5e-22000b9923ed
#!/bin/bash
# Transfers a single file via script.
# Note the optional --encrypt flag.
set -e
globus=`which globus`
srce=c4d80096-7612-11e7-8b5e-22000b9923ef
dest=c4d80096-7612-11e7-8b5e-22000b9923ed
@nmagee
nmagee / dcos-setup.txt
Created September 11, 2018 15:13
Prepares a CentOS cluster for installation of DC/OS.
# DC/OS Prep for Install
#
# The following playbooks should be run, in order, to prep a CentOS cluster for installation of DC/OS.
# This list is based on the software prerequisites published by Mesosphere:
# https://docs.mesosphere.com/1.11/installing/production/system-requirements/
- 1-add-ansible-user.playbook
- 2-install-basics.playbook
- 3-add-nogroup.playbook
- 4-docker.playbook
@nmagee
nmagee / aws-jq-simple-requests.sh
Last active October 2, 2018 20:07
Use JQ to parse AWS CLI requests
#!/bin/bash
# Display the EIPs associated with all of your instances:
aws ec2 describe-instances \
| jq -r .Reservations[].Instances[].PublicIpAddress
# Display the EIP attached to a specific EC2 instance:
aws ec2 describe-instances --instance-ids i-1a2b3c4d5e6f7g8h9i \
| jq -r .Reservations[0].Instances[0].PublicIpAddress