From 6e14e4a9d019ace273bc622af51f0bad510b87ec Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Wed, 22 Apr 2015 15:18:31 -0700 Subject: [PATCH] Docs and tweaks --- README.md | 39 ++++++++++++++++++++++++++++++ sources/savepoint.sh | 6 ++--- stalker.json | 56 +++++++++++++++++++++----------------------- 3 files changed, 68 insertions(+), 33 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..c37ff49 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +### Capture Full Log of Route 27 at Powell + +Deploys an EC2 box that checks each minute the position, speed, +orientation and predicted arrival of route 27. This bus has messed +with me one too many times and now it's time to get even. + +1. Sign up for Amazon Web Services free tier [here](http://aws.amazon.com/free/). + It is **extremely important** to ensure the region in your + Amazon Web Console is set to "N. California" as the defaults + are all configured to use this region in future steps. If you decide + to use a different region you will need to specify the region in future + steps when noted. + +2. Create Amazon IAM credentials for deployment. + Assuming you are signed into the AWS console, visit the [user + admin](https://console.aws.amazon.com/iam/home#users) page. Create + a new user and note their security credentials (ID and secret key). + Then attach a user policy of "Power User" to the newly created user. + +3. [Create EC2 keypair](https://console.aws.amazon.com/ec2/v2/home?region=us-west-1#KeyPairs:sort=keyName). + +4. Clone this repo including its chef recipe submodules. + ```bash + git clone --recursive https://github.com/begriffs/microservice-template.git + ``` + +5. Install Packer. + On a Mac you can use homebrew: + ```bash + brew tap homebrew/binary + brew install packer + ``` +6. Build the AMI + ```bash + packer build -var 'aws_access_key=xxx' -var 'aws_secret_key=xxx' stalker.json + ``` + +7. Launch the AMI from the Amazon Web Console. Then go watch the + files accumulate on your S3 bucket. diff --git a/sources/savepoint.sh b/sources/savepoint.sh index ca28577..b4bb1fb 100755 --- a/sources/savepoint.sh +++ b/sources/savepoint.sh @@ -1,9 +1,7 @@ export WHEN=`date +%s` -curl "http://webservices.nextbus.com/service/publicXMLFeed?command=predictions&a=sf-muni&r=27&s=3813" > r27-p-3813-${WHEN}.xml -curl "http://webservices.nextbus.com/service/publicXMLFeed?command=predictions&a=sf-muni&r=27&s=3612" > r27-p-3612-${WHEN}.xml -curl "http://webservices.nextbus.com/service/publicXMLFeed?command=vehicleLocations&a=sf-muni&r=27&t=0" > r27-l-${WHEN}.xml +curl -i "http://webservices.nextbus.com/service/publicXMLFeed?command=predictions&a=sf-muni&r=27&s=3612" > r27-p-3612-${WHEN}.xml +curl -i "http://webservices.nextbus.com/service/publicXMLFeed?command=vehicleLocations&a=sf-muni&r=27&t=0" > r27-l-${WHEN}.xml -aws s3 cp r27-p-3813-${WHEN}.xml s3://route-27-history/r27-p-3813-${WHEN}.xml aws s3 cp r27-p-3612-${WHEN}.xml s3://route-27-history/r27-p-3612-${WHEN}.xml aws s3 cp r27-l-${WHEN}.xml s3://route-27-history/r27-l-${WHEN}.xml diff --git a/stalker.json b/stalker.json index 0114e54..1411b14 100644 --- a/stalker.json +++ b/stalker.json @@ -1,9 +1,7 @@ { "variables": { "aws_access_key": "", - "aws_secret_key": "", - "broker_id": "", - "base_ami": "" + "aws_secret_key": "" }, "builders": [{ "type": "amazon-ebs", @@ -13,36 +11,36 @@ "source_ami": "ami-4b6f650e", "instance_type": "t2.micro", "ssh_username": "ec2-user", - "ami_name": "Bus Stalker {{timestamp}}", - "ami_groups": ["all"] + "ami_name": "Bus Stalker {{timestamp}}" }], "provisioners": [{ - "type": "file", - "source": "sources/savepoint.sh", - "destination": "/home/ec2-user/savepoint.sh" - }, { - "type": "chef-solo", - "cookbook_paths": ["cookbooks"], - "run_list": [ - "recipe[awscli]" - ], - "json": { - "awscli": { - "config_profiles": { - "default" : { - "region" : "us-west-1", - "aws_access_key_id" : "{{user `aws_access_key`}}", - "aws_secret_access_key" : "{{user `aws_secret_key`}}", - "user" : "ec2-user" + "type": "file", + "source": "sources/savepoint.sh", + "destination": "/home/ec2-user/savepoint.sh" + }, { + "type": "chef-solo", + "cookbook_paths": ["cookbooks"], + "run_list": [ + "recipe[awscli]" + ], + "json": { + "awscli": { + "config_profiles": { + "default" : { + "region" : "us-west-1", + "aws_access_key_id" : "{{user `aws_access_key`}}", + "aws_secret_access_key" : "{{user `aws_secret_key`}}", + "user" : "ec2-user" + } } } } + }, { + "type": "shell", + "inline": [ + "chmod a+x /home/ec2-user/savepoint.sh", + "sudo sh -c 'echo \"* * * * * ec2-user /home/ec2-user/savepoint.sh\" > /etc/crontab'" + ] } - }, { - "type": "shell", - "inline": [ - "chmod a+x /home/ec2-user/savepoint.sh", - "sudo sh -c 'echo \"* * * * * ec2-user /home/ec2-user/savepoint.sh\" > /etc/crontab'" - ] - }] + ] }