Skip to content

Commit 54e902f

Browse files
author
Tom Clark
committed
Added controlling-ec2-from-the-console tutorial
1 parent 7e6a31c commit 54e902f

File tree

3 files changed

+89
-4
lines changed

3 files changed

+89
-4
lines changed

index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ This project originated as a full-blown rails app backed by a database, and I re
1717

1818
All Tutorials
1919
-------------
20-
You can [browse all tutorials here](/pages/table-of-contents.html?1340248769).
20+
You can [browse all tutorials here](/pages/table-of-contents.html?1340490172).
2121

2222
Newest Tutorials
2323
----------------
24-
* [Creating a Production Storm Cluster](/pages/creating-a-production-storm-cluster.html?1340487118)
24+
* [Controlling EC2 from the Console](/pages/controlling-ec2-from-the-console.html?1340490172)
25+
* [Creating a Production Storm Cluster](/pages/creating-a-production-storm-cluster.html?1340487894)
2526
* [Retrieving Storm Cluster Statistics from Nimbus](/pages/retrieving-storm-data-from-nimbus.html?1340398351)
2627
* [Installing MySQL](/pages/installing-mysql.html?1339980010)
2728
* [Hello, World!](/pages/hello-world.html?1339978842)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
layout: default
3+
title: Controlling EC2 from the Console
4+
---
5+
6+
# Controlling EC2 from the Console
7+
8+
[Amazon Web Services'](http://aws.amazon.com/) [Elastic Compute Cloud](http://aws.amazon.com/ec2/) is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale computing easier for developers.
9+
10+
You can control your EC2 instances through the [AWS Management Console](https://console.aws.amazon.com/ec2/), but clicking around can be a chore. This tutorial will help you setup your machine so you can spawn new instances, query existing instances, and do general maintainence without leaving the comfort of a terminal.
11+
12+
<div
13+
markdown="1"
14+
class="tutorial"
15+
data-author-github="Whitespace"
16+
data-license="http://creativecommons.org/licenses/by/3.0/"
17+
data-facets='{"Operating System": "OS X", "Package Management": "Homebrew", "Shell": "bash"}'>
18+
19+
## Assumptions
20+
We assume you've [signed up for EC2](https://aws-portal.amazon.com/gp/aws/developer/registration). We also assume your machine has a public key setup (commonly `~/.ssh/id_rsa` and `~/id_rsa.pub`).
21+
22+
## Download Credential Files
23+
First, you need to download some credential files to your machine. [Download your X.509 certificates](https://portal.aws.amazon.com/gp/aws/securityCredentials) and then put them into your `~/.ec2` directory:
24+
25+
{% highlight sh %}
26+
mkdir ~/.ec2
27+
cp ~/Downloads/[cert,pk]-*.pem ~/.ec2
28+
{% endhighlight %}
29+
30+
## Install the EC2 Command Line Tools
31+
Now let's install the two packages we need:
32+
33+
{% highlight sh %}
34+
brew install ec2-ami-tools
35+
brew install ec2-api-tools
36+
{% endhighlight %}
37+
38+
Copy the following to your `~/.bash_profile`:
39+
40+
{% highlight sh %}
41+
export JAVA_HOME="$(/usr/libexec/java_home)"
42+
export EC2_PRIVATE_KEY="$(/bin/ls "$HOME"/.ec2/pk-*.pem | /usr/bin/head -1)"
43+
export EC2_CERT="$(/bin/ls "$HOME"/.ec2/cert-*.pem | /usr/bin/head -1)"
44+
export EC2_HOME="/usr/local/Library/LinkedKegs/ec2-api-tools/jars"
45+
export AWS_ACCESS_KEY_ID="..."
46+
export AWS_SECRET_ACCESS_KEY"=..."
47+
{% endhighlight %}
48+
49+
Where `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` are available from the "Access Keys" tab on the [https://portal.aws.amazon.com/gp/aws/securityCredentials](Amazon Security Credentials page).
50+
51+
And we
52+
53+
## Uploading your Access Keys
54+
Some people use the public/private keys that Amazon gives them, but I find it easier to use the same public key on my laptop that I already use for things like Github and servers at work. To upload, you can use [this helpful script from Eric Hammond](http://alestic.com/2010/10/ec2-ssh-keys) (slightly modified):
55+
56+
{% highlight sh %}
57+
keypair=macbook # Choose something that makes sense, like your computer name
58+
publickeyfile=$HOME/.ssh/id_rsa.pub # Point this to the public key you want to use
59+
regions=$(ec2-describe-regions | cut -f2)
60+
61+
for region in $regions; do
62+
echo $region
63+
ec2-import-keypair --region $region --public-key-file $publickeyfile $keypair
64+
done
65+
{% endhighlight %}
66+
67+
## Test it All Works
68+
Once we've done all that, we can test it by doing:
69+
70+
{% highlight sh %}
71+
ec2-describe-instances
72+
{% endhighlight %}
73+
74+
If you don't see an error, you're all set!
75+
76+
## References
77+
These links were helpful in getting my machine setup and writing this tutorial:
78+
79+
* [Starting Amazon EC2 with Mac OS X](http://www.robertsosinski.com/2008/01/26/starting-amazon-ec2-with-mac-os-x/)
80+
* [Uploading Personal ssh Keys to Amazon EC2](http://alestic.com/2010/10/ec2-ssh-keys)
81+
</div>

pages/table-of-contents.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ title: Table of Contents
44
ignore: true
55
---
66

7-
This is the TOC. It should not be edited
7+
# All Tutorials
8+
9+
<!-- THIS FILE IS GENERATED; PLEASE DO NOT EDIT THIS FILE BY HAND -->
810

911
<!--- BEGIN TOC -->
10-
* [Creating a Production Storm Cluster](/pages/creating-a-production-storm-cluster.html?1340487118)
12+
* [Controlling EC2 from the Console](/pages/controlling-ec2-from-the-console.html?1340490172)
13+
* [Creating a Production Storm Cluster](/pages/creating-a-production-storm-cluster.html?1340487894)
1114
* [Retrieving Storm Cluster Statistics from Nimbus](/pages/retrieving-storm-data-from-nimbus.html?1340398351)
1215
* [Installing MySQL](/pages/installing-mysql.html?1339980010)
1316
* [Hello, World!](/pages/hello-world.html?1339978842)

0 commit comments

Comments
 (0)