<?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>Xi Group Ltd. Company Blog &#187; Xi Group Ltd. Company Blog &#187; extract fields</title>
	<atom:link href="http://blog.xi-group.com/tag/extract-fields/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xi-group.com</link>
	<description>High-quality DevOps Services</description>
	<lastBuildDate>Tue, 09 Jun 2015 11:38:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2.2</generator>
	<item>
		<title>Small Tip: How to use AWS CLI &#8216;&#8211;filter&#8217; parameter</title>
		<link>http://blog.xi-group.com/2015/01/small-tip-how-to-use-aws-cli-filter-parameter/</link>
		<comments>http://blog.xi-group.com/2015/01/small-tip-how-to-use-aws-cli-filter-parameter/#comments</comments>
		<pubDate>Tue, 20 Jan 2015 12:20:54 +0000</pubDate>
		<dc:creator><![CDATA[Ivo Vachkov]]></dc:creator>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Operations]]></category>
		<category><![CDATA[Small Tip]]></category>
		<category><![CDATA[AWS CLI]]></category>
		<category><![CDATA[extract fields]]></category>
		<category><![CDATA[filter parameter]]></category>
		<category><![CDATA[output filter]]></category>
		<category><![CDATA[parse output]]></category>

		<guid isPermaLink="false">http://blog.xi-group.com/?p=362</guid>
		<description><![CDATA[This post will present another, useful feature of the AWS CLI tool set, the &#8211;filter parameter. This command line parameter is available and extremely helpful in EC2 namespace (aws ec2 describe-*).There are various ways to use &#8211;filter parameter. 1. &#8211;filter parameter can get filtering properties directly from the command line: [crayon-69d09a558143b528811998/] 2. &#8211;filter parameter will [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="text-align: justify;">This post will present another, useful feature of the AWS CLI tool set, the <strong>&#8211;filter</strong> parameter. This command line parameter is available and extremely helpful in EC2 namespace (aws ec2 describe-*).There are various ways to use <strong>&#8211;filter</strong> parameter.</p>
<p style="text-align: justify;">1. <strong>&#8211;filter</strong> parameter can get filtering properties directly from the command line:</p>
<p></p><pre class="crayon-plain-tag">aws ec2 describe-instances --filter Name="instance-id",Values="i-1234abcd"</pre><p></p>
<p style="text-align: justify;">2. <strong>&#8211;filter</strong> parameter will also use JSON-encoded filter file:</p>
<p></p><pre class="crayon-plain-tag">aws ec2 describe-instances --filters file://filters.json</pre><p></p>
<p>The <strong>filters.json</strong> file uses the following structure:</p>
<p></p><pre class="crayon-plain-tag">[
  {
    "Name": "instance-type",
    "Values": ["m1.small", "m1.medium"]
  },
  {
    "Name": "availability-zone",
    "Values": ["us-west-2c"]
  }
]</pre><p></p>
<p style="text-align: justify;">There are various AWS CLI components that provide <strong>&#8211;filter</strong> parameters. For additional information check the <em>References</em> section.</p>
<p>To demonstrate the way this functionality can be used in various scenarios, there are several examples:</p>
<p>1. Filter by availability zone:</p><pre class="crayon-plain-tag">aws ec2 describe-instances --filter Name="availability-zone",Values="us-east-1b"</pre><p></p>
<p>2. Filter by security group (EC2-Classic):</p><pre class="crayon-plain-tag">aws ec2 describe-instances --filter Name="group-name",Values="default"</pre><p></p>
<p>3. Filter by security group (EC2-VPC):</p><pre class="crayon-plain-tag">aws ec2 describe-instances --filter Name="instance.group-name",Values="default"</pre><p></p>
<p>4. Filter only spot instances</p><pre class="crayon-plain-tag">aws ec2 describe-instances --filter Name="instance-lifecycle",Values="spot"</pre><p></p>
<p>5. Filter only running EC2 instances:</p><pre class="crayon-plain-tag">aws ec2 describe-instances --filter Name="instance-state-name",Values="running"</pre><p></p>
<p>6. Filter only stopped EC2 instances:</p><pre class="crayon-plain-tag">aws ec2 describe-instances --filter Name="instance-state-name",Values="stopped"</pre><p></p>
<p>7. Filter by SSH Key name</p><pre class="crayon-plain-tag">aws ec2 describe-instances --filter Name="key-name",Values="ssh-key"</pre><p></p>
<p>8. Filter by Tag:</p><pre class="crayon-plain-tag">aws ec2 describe-instances --filter "Name=tag-key,Values=Name" "Name=tag-value,Values=string"</pre><p></p>
<p>9. Filter by Tag with a wildcard (&#8216;*&#8217;):</p><pre class="crayon-plain-tag">aws ec2 describe-instances --filter "Name=tag-key,Values=MyTag" "Name=tag-value,Values=abcd*efgh"</pre><p></p>
<p>10. Filter by multiple criteria (all running instances with string &#8217;email&#8217; in the value of the Name tag):</p><pre class="crayon-plain-tag">aws ec2 describe-instances --filter "Name=instance-state-name,Values=running" "Name=tag-key,Values=Name" "Name=tag-value,Values=*email*"</pre><p></p>
<p>11. Filter by multiple criteria (all running instances with empty Name tag);</p><pre class="crayon-plain-tag">aws ec2 describe-instances --filter "Name=instance-state-name,Values=running" "Name=tag-key,Values=Name" "Name=tag-value,Values=''"</pre><p></p>
<p>Those examples are very close to production ones used in several large AWS deployments. They are used to:</p>
<ul>
<li>Monitor changes in instance populations;</li>
<li>Monitor successful configuration of resources;</li>
<li>Track deployment / rollout of new software version;</li>
<li>Track stopped instances to prevent unnecessary resource usage;</li>
<li>Ensure desired service distributions over availability zones and regions;</li>
<li>Ensure service distribution over instances with different lifecycle;</li>
</ul>
<p>Be sure to utilize this functionality in your monitoring infrastructure. It has been powerful source of operational insights and great source of raw data for our intelligent control planes!</p>
<p>If you want to talk more on this subject or just share your experience, do not hesitate to <a href="http://blog.xi-group.com/contact-us/" target="_blank">Contact Us!</a></p>
<p>References</p>
<ul>
<li><a href="http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html">http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html</a></li>
<li><a href="http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-spot-instance-requests.html">http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-spot-instance-requests.html</a></li>
<li><a href="http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-reserved-instances.html">http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-reserved-instances.html</a></li>
<li><a href="http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-network-acls.html">http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-network-acls.html</a></li>
<li><a href="http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-key-pairs.html">http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-key-pairs.html</a></li>
<li><a href="http://docs.aws.amazon.com/cli/latest/reference/ec2/index.html">http://docs.aws.amazon.com/cli/latest/reference/ec2/index.html</a></li>
</ul>
<div class="rpbt_shortcode">
<h3>Related Posts</h3>
<ul>
					
			<li><a href="http://blog.xi-group.com/2014/11/small-tip-how-to-use-block-device-mappings-to-manage-instance-volumes-with-aws-cli/">Small Tip: How to use &#8211;block-device-mappings to manage instance volumes with AWS CLI</a></li>
					
			<li><a href="http://blog.xi-group.com/2014/07/small-tip-how-to-use-aws-cli-to-start-spot-instances-with-userdata/">Small Tip: How to use AWS CLI to start Spot instances with UserData</a></li>
					
			<li><a href="http://blog.xi-group.com/2014/06/small-tip-ebs-volume-allocation-time-is-linear-to-the-size-and-unrelated-to-the-instance-type/">Small Tip: EBS volume allocation time is linear to the size and unrelated to the instance type</a></li>
					
			<li><a href="http://blog.xi-group.com/2015/02/how-to-deploy-single-node-hadoop-setup-in-aws/">How to deploy single-node Hadoop setup in AWS</a></li>
					
			<li><a href="http://blog.xi-group.com/2015/01/userdata-teplate-for-ubuntu-14-04-ec2-instances-in-aws/">UserData Template for Ubuntu 14.04 EC2 Instances in AWS</a></li>
			</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.xi-group.com/2015/01/small-tip-how-to-use-aws-cli-filter-parameter/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
