<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Curious &#187; Scala</title>
	<atom:link href="http://blogs.plexibus.com/category/scala/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.plexibus.com</link>
	<description>It&#039;s easy if you know how</description>
	<lastBuildDate>Tue, 22 Jun 2010 14:45:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Amazon EC2 Reservation ID and one of it&#8217;s uses</title>
		<link>http://blogs.plexibus.com/2010/02/23/amazon-ec2-reservation-id-and-one-of-its-uses/</link>
		<comments>http://blogs.plexibus.com/2010/02/23/amazon-ec2-reservation-id-and-one-of-its-uses/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 04:37:50 +0000</pubDate>
		<dc:creator>roshanallan</dc:creator>
				<category><![CDATA[Appistry]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[amazon ec2 reservation id st. louis cloud computing user group]]></category>

		<guid isPermaLink="false">http://blogs.plexibus.com/2010/02/23/amazon-ec2-reservation-id-and-one-of-its-uses/</guid>
		<description><![CDATA[At this month&#8217;s St. Louis Cloud Computing User Group a question was posed: 
What does Reservation id mean when an AMI instance is provisioned? And what is it&#8217;s use?
If you do not know what I&#8217;m talking about, see the following command ec2-run-instances (and it&#8217;s output) which is used to launch any number of instances of [...]]]></description>
			<content:encoded><![CDATA[<p>At this <a href="http://stlcloudusers.org/2010/02/february-meeting-details/" target="_blank">month</a>&#8217;s <a href="http://stlcloudusers.org/" target="_blank">St. Louis Cloud Computing User Group</a> a question was posed: </p>
<blockquote><p>What does <i>Reservation id</i> mean when an <a href="http://aws.amazon.com/ec2/" target="_blank">AMI</a> instance is provisioned? And what is it&#8217;s use?</p></blockquote>
<p>If you do not know what I&#8217;m talking about, see the following command <font face="Courier New">ec2-run-instances</font> (and it&#8217;s output) which is used to launch any number of instances of a specified Amazon AMI:</p>
<pre class="java-codeface">
roshan@roshan:~/.ec2$ ec2-run-instances ami-cddf39a4
</pre>
<div style="width: 90%; border: 1px solid black; background-color: #000; font-size: 11px; color: #FFF">
[Deprecated] Xalan: org.apache.xml.res.XMLErrorResources_en_US<br />
RESERVATION	r-06acd26e	365788654425	default<br />
INSTANCE	i-2358b248	ami-cddf39a4			pending	roshmac-keypair	0		m1.small	2010-02-19T15:04:28+0000	us-east-1d			windows	monitoring-disabled		instance-store
</div>
<p>In the above output the <font face="Courier New">RESERVATION ID</font> is <font face="Courier New">r-06acd26e</font>.</p>
<p>At the meeting I attempted to answer that question by waving my arms in a very mumbo jumbo sort of way. Pretty much like how those marketing/sales guys you meet do <img src='http://blogs.plexibus.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (j/k)<br />
I did not make sense at all. Therefore I decided to spend some time putting my thoughts down in this post.</p>
<p><strong>Reservation</strong><br />
A reservation in the above context is an atomic launch of one or many instances. One reservation does not imply a single reserved instance. For example, if you launch 1 instance, you get 1 instance ID and 1 reservation ID. If you launch 2 instances in a single <font face="Courier New">ec2-run-instances</font> command, you get 2 instance IDs, but still 1 reservation ID. Likewise if you launch <i>N</i> instances in a single <font face="Courier New">ec2-run-instances</font> command, you still get only 1 reservation ID.</p>
<p><strong>Use</strong><br />
Since a reservation is an atomic launch and the reservation id serves as an identifier to a <i>group</i> of instances, you could use it, for instance, to terminate the entire reservation of instances. The attached <a href="http://www.scala-lang.org/" target="_blank">Scala</a> script does just that! It takes a reservation id as a parameter, gets the list of instances in that reservation and then terminates those instances. This script saves you the trouble of terminating each instance manually.</p>
<p>Let&#8217;s see this script (using reservation id) in action. Let&#8217;s start 5 instances of an AMI.</p>
<pre class="java-codeface">
roshan@roshan:~/.ec2$ ec2-run-instances ami-cddf39a4 -n 5
</pre>
<div style="width: 90%; border: 1px solid black; background-color: #000; font-size: 11px; color: #FFF">
[Deprecated] Xalan: org.apache.xml.res.XMLErrorResources_en_US<br />
RESERVATION	r-72feba1a	365788654425	default<br />
INSTANCE	i-f1ac539a	ami-cddf39a4			pending	roshmac-keypair	0		m1.small	2010-02-24T04:05:48+0000	us-east-1d	windows	monitoring-disabled					instance-store<br />
INSTANCE	i-f7ac539c	ami-cddf39a4			pending	roshmac-keypair	1		m1.small	2010-02-24T04:05:48+0000	us-east-1d	windows	monitoring-disabled					instance-store<br />
INSTANCE	i-f5ac539e	ami-cddf39a4			pending	roshmac-keypair	2		m1.small	2010-02-24T04:05:48+0000	us-east-1d	windows	monitoring-disabled					instance-store<br />
INSTANCE	i-cbac53a0	ami-cddf39a4			pending	roshmac-keypair	3		m1.small	2010-02-24T04:05:48+0000	us-east-1d	windows	monitoring-disabled					instance-store<br />
INSTANCE	i-c9ac53a2	ami-cddf39a4			pending	roshmac-keypair	4		m1.small	2010-02-24T04:05:48+0000	us-east-1d	windows	monitoring-disabled					instance-store
</div>
<p>Now, to delete all instances under reservation id <font face="Courier New">r-72feba1a</font>, all I have to do is the following:</p>
<pre class="java-codeface">
roshan@roshan:~/.ec2$ ec2-terminate-reservation r-72feba1a
</pre>
<div style="width: 90%; border: 1px solid black; background-color: #000; font-size: 11px; color: #FFF">
Instance ids: List(i-c9ac53a2, i-cbac53a0, i-f5ac539e, i-f7ac539c, i-f1ac539a)<br />
INSTANCE	i-f7ac539c	pending	shutting-down<br />
INSTANCE	i-c9ac53a2	pending	shutting-down<br />
INSTANCE	i-f5ac539e	pending	shutting-down<br />
INSTANCE	i-f1ac539a	pending	shutting-down<br />
INSTANCE	i-cbac53a0	pending	shutting-down<br />
[Deprecated] Xalan: org.apache.xml.res.XMLErrorResources_en_US
</div>
<p>As you can see from the above output of <font face="Courier New">ec2-terminate-reservation</font>, the instances are now in the <font face="Courier New">shutting-down</font> state</p>
<p><font face="Courier New">ec2-describe-instances</font> confirms that the instances are being shutdown</p>
<pre class="java-codeface">
roshan@roshan:~/.ec2$ ec2-describe-instances
</pre>
<div style="width: 90%; border: 1px solid black; background-color: #000; font-size: 11px; color: #FFF">
[Deprecated] Xalan: org.apache.xml.res.XMLErrorResources_en_US<br />
RESERVATION	r-36da9e5e	365788654425	default<br />
INSTANCE	i-e7728e8c	ami-9dde38f4			terminated		0		m1.small	2010-02-24T02:33:32+0000	us-east-1d	windows	monitoring-disabled					instance-store<br />
INSTANCE	i-e5728e8e	ami-9dde38f4			terminated		1		m1.small	2010-02-24T02:33:32+0000	us-east-1d	windows	monitoring-disabled					instance-store<br />
RESERVATION	r-72feba1a	365788654425	default<br />
INSTANCE	i-f1ac539a	ami-cddf39a4	ec2-184-73-35-115.compute-1.amazonaws.com	ip-10-242-193-159.ec2.internal	shutting-down	roshmac-keypair	0	m1.small	2010-02-24T04:05:48+0000	us-east-1d			windows	monitoring-disabled	184.73.35.115	10.242.193.159			instance-store<br />
INSTANCE	i-f7ac539c	ami-cddf39a4	ec2-67-202-43-95.compute-1.amazonaws.com	ip-10-243-23-239.ec2.internal	shutting-down	roshmac-keypair	1	m1.small	2010-02-24T04:05:48+0000	us-east-1d			windows	monitoring-disabled	67.202.43.95	10.243.23.239			instance-store<br />
INSTANCE	i-f5ac539e	ami-cddf39a4	ec2-184-73-10-172.compute-1.amazonaws.com	ip-10-243-25-175.ec2.internal	shutting-down	roshmac-keypair	2	m1.small	2010-02-24T04:05:48+0000	us-east-1d			windows	monitoring-disabled	184.73.10.172	10.243.25.175			instance-store<br />
INSTANCE	i-cbac53a0	ami-cddf39a4	ec2-174-129-77-181.compute-1.amazonaws.com	ip-10-242-73-220.ec2.internal	shutting-down	roshmac-keypair	3	m1.small	2010-02-24T04:05:48+0000	us-east-1d			windows	monitoring-disabled	174.129.77.181	10.242.73.220			instance-store<br />
INSTANCE	i-c9ac53a2	ami-cddf39a4	ec2-75-101-231-29.compute-1.amazonaws.com	ip-10-242-77-126.ec2.internal	shutting-down	roshmac-keypair	4	m1.small	2010-02-24T04:05:48+0000	us-east-1d			windows	monitoring-disabled	75.101.231.29	10.242.77.126			instance-store
</div>
<p><strong>How to use <font face="Courier New">ec2-terminate-reservation</font></strong><br />
Download the attached <font face="Courier New">ec2-terminate-reservation.sh</font> script to your <font face="Courier New">$EC2_HOME/bin</font> directory, rename it to ec2-terminate-reservation and make it executable. </p>
<pre class="java-codeface">
roshan@roshan:~/.ec2$ chmod +x ec2-terminate-reservation
</pre>
<p>You should have <a href="http://www.scala-lang.org/downloads" target="_blank">Scala</a> installed and the <font face="Courier New">$SCALA_HOME/bin</font> appended to your <font face="Courier New">PATH</font> for the script to work.</p>
<p><strong><a href="http://blogs.plexibus.com/wp-content/uploads/2010/02/ec2-terminate-reservation.sh">ec2-terminate-reservation</a></strong></p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=d85bfd0f-9b40-83dc-a7a1-c7e30ab332df" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.plexibus.com/2010/02/23/amazon-ec2-reservation-id-and-one-of-its-uses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.156 seconds -->
