Skip to content

Instantly share code, notes, and snippets.

@ajkerrigan
ajkerrigan / aws-mfa.sh
Created May 23, 2017 03:12
Create and activate an MFA-required temporary session with the AWS CLI, based on the current profile
#!/bin/bash
#
# Provide basic support for MFA-required temporary sessions with the AWS CLI.
# While not a hard dependency, this script plays nicely with zsh and the
# aws plugin for oh-my-zsh. jq is required.
#
# https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/aws/aws.plugin.zsh
# https://stedolan.github.io/jq/manual/
#
# Usage:
@ajkerrigan
ajkerrigan / awsfind.sh
Created February 6, 2017 15:21
Find AWS VPC Resources by IP/DNS
#!/bin/bash
usage()
{
echo "Find AWS resources using network interface information."
echo "Usage: $0 {pri|pub|dns} <comma-separated list>"
echo
echo "pri: Private IP Address"
echo "pub: Public IP Address"
echo "dns: Public DNS Name"
@ajkerrigan
ajkerrigan / cwlastlog.sh
Last active July 12, 2016 13:55
Get the most recent Cloudwatch log messages for a specified AWS Lambda function (requires the AWS CLI and jq)
#!/bin/bash
#
# Usage: cwlastlog.sh <Lambda function name>
LAMBDA_FUNCTION="${1}"
MESSAGE_LIMIT=50
# Get the name of the log stream with the most recent activity for this log group
LAST_LOG_STREAM=`aws logs describe-log-streams --log-group-name "/aws/lambda/${LAMBDA_FUNCTION}" \
--descending --order-by LastEventTime --max-items 1 | jq --raw-output '.logStreams[0].logStreamName'`