Skip to content

Instantly share code, notes, and snippets.

import boto3
profile = "my_profile"
region = "my_region"
expiration = 3600 # one hour in seconds
bucket = "my_bucket"
key = "my_file_name"
session = boto3.session.Session(profile_name=profile, region_name=region)
@coingraham
coingraham / Terraform_Instance_Attachment_ID.go
Last active January 19, 2018 21:24
Terraform Go code for generating the instance attachment IDs
// Update the variables below from the output of your terraform apply, assuming the attachment name is "attachment".
// Then paste this into https://play.golang.org/ and run it. This example is here https://play.golang.org/p/UgXxMqbdxH
// Copied from the terraform code directly at https://github.com/hashicorp/terraform
// output "attachment_name" {
// value = "${aws_volume_attachment.attachment.device_name}"
// }
// output "attachment_instance_id" {
// value = "${aws_volume_attachment.attachment.instance_id}"
CREATE EXTERNAL TABLE cloudtrail_logs (
eventversion STRING,
userIdentity STRUCT<
type:STRING,
principalid:STRING,
arn:STRING,
accountid:STRING,
invokedby:STRING,
accesskeyid:STRING,
userName:STRING,
@coingraham
coingraham / hostname_get_userdata.sh
Last active April 28, 2017 13:57
Userdata Retrieval based on Hostname
#!/bin/bash
# Given the name of an instance, it will lookup the instance ID and download the UserData.
NAME=$1
PROFILE=$2
REGION=$3
if [ -z $NAME ] ; then
echo "Usage: $0 <instance_name>"
@coingraham
coingraham / hostname_get_userdata.sh
Created April 12, 2017 13:13
Userdata Retrieval based on Hostname
#!/bin/bash
# Given the name of an instance, it will lookup the instance ID and download the UserData.
NAME=$1
if [ -z $NAME ] ; then
echo "Usage: $0 <instance_name>"
exit 1
fi
@coingraham
coingraham / cloudtrail.sql
Last active April 4, 2017 22:13
Create an Althena Database for CloudTrail Queries
CREATE EXTERNAL TABLE cloud_trail (
Records ARRAY< STRUCT< eventName: STRING,
requestParameters: STRUCT< instancesSet: STRUCT< items: ARRAY< STRUCT< instanceId: STRING >>>,
volumeSet: STRUCT< items: ARRAY< STRUCT< volumeId: STRING > > > >,
eventType: STRING,
eventSource: STRING,
sourceIPAddress: STRING,
userIdentity: STRUCT< arn: STRING,
principalId: STRING,
accountId: STRING,
@coingraham
coingraham / getuserdata.sh
Created April 3, 2017 21:19
Userdata Retrieval
aws ec2 describe-instance-attribute --instance-id [id] --region us-west-2 --profile [profile] --attribute userData --query '{data:UserData}' --output text | awk '{print $NF}' | base64 -d > filename.userdata
@coingraham
coingraham / connectivity.sh
Created March 16, 2017 19:03 — forked from mlconnor/connectivity.sh
Diagnose Connectivity
#set -o xtrace
echo "please copy the output of this script and send it to the network team so they can diagnose your issue"
DESTINATION=destination.foo.com
PORT=8089
echo "Dumping local network data"
ifconfig
# get the routing table
@coingraham
coingraham / website-checker.sh
Last active March 13, 2017 21:44 — forked from dominic-p/website-checker.sh
This is a shell script to check a provided list of URLs to see if the websites are working or not. It was based on the answers provided to this question: http://stackoverflow.com/q/21391776/931860
#!/bin/sh
# ---- website-checker.sh ----
# Pings a list of websites using cURL to see if they are up and
# there are no errors. If there are problems, we send an email using mailx
# to let ourselves know about the problem.
################################################################################
# This is a path to a plain text list of URLs to check, one per line
# Make sure this uses proper unix newline characters or you will get 400 Bad Request errors
# when you try to curl the URLs
@coingraham
coingraham / New_VPC.yaml
Last active May 25, 2021 16:08
multiaz-vpc with redundant nat gateways. New updated with Yaml
Description: This template deploys a VPC, with a pair of public and private subnets spread
across two Availability Zones. It deploys an internet gateway, with a default
route on the public subnets. It deploys a pair of NAT gateways (one in each AZ),
and default routes for them in the private subnets.
Parameters:
EnvironmentName:
Description: An environment name that is prefixed to resource names
Type: String