{"id":1743,"date":"2020-03-23T17:43:52","date_gmt":"2020-03-23T14:43:52","guid":{"rendered":"https:\/\/artem.services\/?p=1741"},"modified":"2022-02-25T23:06:05","modified_gmt":"2022-02-25T20:06:05","slug":"1743","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1743&lang=en","title":{"rendered":"AWS Cli &#8212; Search EC2 instances by tag and state"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-214\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo.png\" alt=\"\" width=\"975\" height=\"450\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo.png 975w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-300x138.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-768x354.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-954x440.png 954w\" sizes=\"(max-width: 975px) 100vw, 975px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>To get the <strong>IP<\/strong> addresses of all instances with the &quot;<strong>Application<\/strong>&quot; tag and its value &quot;<strong>Frontend<\/strong>&quot;, and also filter by state to display information about only those instances that are in the &quot;<strong>running<\/strong>&quot; state:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\naws ec2 describe-instances --filter &quot;Name=tag:Application,Values=Frontent&quot; &quot;Name=instance-state-name,Values=running&quot; --query &quot;Reservations[*].Instances[*][NetworkInterfaces[0].PrivateIpAddresses[0].PrivateIpAddress]&quot; --output text\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>To display the name of instance along with the <strong>IP<\/strong> address:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\naws ec2 describe-instances --filter &quot;Name=tag:Application,Values=Frontend&quot; &quot;Name=instance-state-name,Values=running&quot; --query &quot;Reservations[*].Instances[*][Tags[?Key=='Name'].Value[],NetworkInterfaces[0].PrivateIpAddresses[0].PrivateIpAddress]&quot; --output text\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; To get the IP addresses of all instances with the &quot;Application&quot; tag and its value &quot;Frontend&quot;, and also filter by state to display information about only those instances that are in the &quot;running&quot; state: &nbsp; To display the name of instance along with the IP address:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[599],"tags":[1397,543,647,545,1399,1401],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1743"}],"collection":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1743"}],"version-history":[{"count":4,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1743\/revisions"}],"predecessor-version":[{"id":2220,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1743\/revisions\/2220"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}