Skip to content

Instantly share code, notes, and snippets.

View davidkelley's full-sized avatar

David Kelley davidkelley

View GitHub Profile
@davidkelley
davidkelley / gist:cc3c90123aeb640a8758
Last active August 29, 2015 14:17
Retrieve comma-delimited list of Private IP addresses for EC2 instances in the same Autoscalinggroup
1. Describe tags for the instance itself and retrieve the autoscaling group name
GROUP=$(ec2-describe-tags --filter "resource-type=instance" --filter "resource-id=$(curl http://169.254.169.254/latest/meta-data/instance-id)" --filter "key=aws:autoscaling:groupName" | cut -f5)
2. Grab all the EC2 instance IDs for that autoscaling group
IDS=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $GROUP --query 'AutoScalingGroups[0].Instances[].InstanceId' --output text | sed 's/\t/ /g')
3. For each instance-id, grab the private IP address of the instance
@davidkelley
davidkelley / gist:741c64a3d623e9eaa3a8
Created March 27, 2015 15:43
Determine oldest instance inside AutoScalingGroup using LaunchTime
GROUP=$(ec2-describe-tags --filter "resource-type=instance" --filter "resource-id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)" --filter "key=aws:autoscaling:groupName" | cut -f5)
IDS=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $GROUP --query 'AutoScalingGroups[0].Instances[].InstanceId' --output text | sed 's/\t/ /g')
IPS=$(aws ec2 describe-instances --instance-ids $IDS --region us-east-1 --query Reservations[].Instances[].PrivateIpAddress --output text | sed 's/\t/,/g')
LAUNCH_TIME=$(date -d $(aws ec2 describe-instances --instance-ids `curl -s http://169.254.169.254/latest/meta-data/instance-id` --query Reservations[].Instances[0].LaunchTime --output text))
LAUNCH_TIMES=$(aws ec2 describe-instances --instance-ids $IDS --region us-east-1 --query Reservations[].Instances[].LaunchTime --output text)
@davidkelley
davidkelley / README.md
Last active September 6, 2015 14:42
AWS Cloudformation integrated Task Scheduler

DynamoDB Table

| string:Hash | string | string | string | string | string | string | |------|---|---|---|---|---|---|---| | Id | StartTime | EndTime | Recurrence | Type | Name | Message |

Scheduler Cloudformation

  1. Creates DynamoDB table: scheduler_table
  2. Creates Lambda function to act as Cloudformation custom resource
@davidkelley
davidkelley / module.js
Last active January 12, 2021 16:33
AWS Request Signer V4 Javascript for jQuery AJAX
// Allows you to make signed requests by wrapping your original request object
// inside the Signer() function, then simply passing the return value to $.ajax.
//
// @note Depends on the CryptoJS library being present
//
// $.ajax(Signer(credentials, {
// url: 'https://xxxxxx.execute-api.us-east-1.amazonaws.com/v1/private',
// type: 'POST',
// context: this,
// dataType: 'json',
@davidkelley
davidkelley / README.md
Created February 16, 2016 14:45
Invisible App - Text Service

Text Service

Stockflare would like to provide a "text us" service, which enables users to text a SMS number with a particular Symbol and receive the latest information about that stock.

Example

Text: "aapl"

Response: "Apple Inc latest share price is $101.43 ($167.00/$96.00). Stockflare rates at 4/5. See more at: https://stockflare.com/stocks/aapl.o"
temp
text
1600 test
@davidkelley
davidkelley / test-2103
Created April 6, 2018 20:03
test-2103
tet-2103