-
-
Save Prajithp/bcf71c5b8f40bbea8608401942d8506a to your computer and use it in GitHub Desktop.
Revisions
-
carlessanagustin revised this gist
Jun 6, 2016 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,13 +3,15 @@ (https://github.com/mwilliamson/jq.py) ``` aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | select(.State.Code != 48) | select(.Tags[]|select(.Key=="Name")|select(.Value=="InstanceName")) | [ .PublicIpAddress]' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | select(.State.Code != 48) | select(.Tags[]|select(.Key=="Name")|select(.Value=="InstanceName")) | [ .PublicIpAddress, (.Tags[]|select(.Key=="Name").Value)]' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | select(.State.Code != 48) | select(.Tags[]|select(.Key=="InventoryGroup").Value) | [ .PublicIpAddress, (.Tags[]|select(.Key=="Name").Value)]' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.LaunchTime > "2015-01-28") | select(.State.Code != 48) | [.LaunchTime, .State.Name, (.Tags[]|select(.Key=="Name")|.Value)]' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | { KeyName, PublicIpAddress}' ``` ## Via AWS CLI using filters -
carlessanagustin revised this gist
Jun 6, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,9 +7,9 @@ aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.LaunchTim aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | { KeyName, PublicIpAddress}' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | select(.State.Code != 48) | select(.Tags[]|select(.Key=="Name")|select(.Value=="InstanceName")) | [ .PublicIpAddress]' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | select(.State.Code != 48) | select(.Tags[]|select(.Key=="Name")|select(.Value=="InstanceName")) | [ .PublicIpAddress, (.Tags[]|select(.Key=="Name").Value)]' ``` ## Via AWS CLI using filters -
carlessanagustin revised this gist
Jun 6, 2016 . 1 changed file with 14 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,17 @@ ## Via AWS CLI using jq (https://github.com/mwilliamson/jq.py) ``` aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.LaunchTime > "2015-01-28") | select(.State.Code != 48) | [.LaunchTime, .State.Name, (.Tags[]|select(.Key=="Name")|.Value)]' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | { KeyName, PublicIpAddress}' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | select(.State.Code != 48) | select(.Tags[]|select(.Key=="Name")|select(.Value=="InstanceName")) | [ .PublicIpAddress]' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | select(.State.Code != 48) | select(.Tags[]|select(.Key=="Name")|select(.Value=="InstanceName")) | [ .PublicIpAddress, (.Tags[]|select(.Key=="Name").Value)]' ``` ## Via AWS CLI using filters (http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html) @@ -47,20 +61,6 @@ filters.json: ] ``` ## Via Ansible ec2.py using jq (http://docs.ansible.com/ansible/intro_dynamic_inventory.html) -
carlessanagustin revised this gist
Jun 6, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -57,6 +57,8 @@ aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.LaunchTim aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | { KeyName, PublicIpAddress}' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | select(.State.Code != 48) | select(.Tags[]|select(.Key=="Name")|select(.Value=="InstanceName")) | [ .PublicIpAddress]' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | select(.State.Code != 48) | select(.Tags[]|select(.Key=="Name")|select(.Value=="InstanceName")) | [ .PublicIpAddress, (.Tags[]|select(.Key=="Name").Value)]' ``` ## Via Ansible ec2.py using jq -
carlessanagustin revised this gist
Jun 6, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,6 +55,8 @@ filters.json: aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.LaunchTime > "2015-01-28") | select(.State.Code != 48) | [.LaunchTime, .State.Name, (.Tags[]|select(.Key=="Name")|.Value)]' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | { KeyName, PublicIpAddress}' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | select(.State.Code != 48) | select(.Tags[]|select(.Key=="Name")|select(.Value=="InstanceName")) | [ .PublicIpAddress]' ``` ## Via Ansible ec2.py using jq -
carlessanagustin revised this gist
Jun 6, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ## Via AWS CLI using filters (http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html) @@ -47,7 +47,7 @@ filters.json: ] ``` ## Via AWS CLI using jq (https://github.com/mwilliamson/jq.py) -
carlessanagustin revised this gist
Jun 6, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -59,6 +59,8 @@ aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName = ## Via Ansible ec2.py using jq (http://docs.ansible.com/ansible/intro_dynamic_inventory.html) ``` ./ec2.py | jq '.tag_Environment_production' -
carlessanagustin revised this gist
Jun 6, 2016 . No changes.There are no files selected for viewing
-
carlessanagustin revised this gist
Jun 6, 2016 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,4 +55,12 @@ filters.json: aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.LaunchTime > "2015-01-28") | select(.State.Code != 48) | [.LaunchTime, .State.Name, (.Tags[]|select(.Key=="Name")|.Value)]' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | { KeyName, PublicIpAddress}' ``` ## Via Ansible ec2.py using jq ``` ./ec2.py | jq '.tag_Environment_production' ./ec2.py | jq '.key_MyKey' ``` -
carlessanagustin revised this gist
Jun 6, 2016 . 1 changed file with 28 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,11 +20,39 @@ aws ec2 describe-instances --filters "Name=tag-key,Values=Owner" aws ec2 describe-instances --filters "Name=tag:Purpose,Values=test" ``` * To describe all EC2 instances that have an instance type of m1.small or m1.medium that are also in the us-west-2c Availability Zone ``` aws ec2 describe-instances --filters "Name=instance-type,Values=m1.small,m1.medium" "Name=availability-zone,Values=us-west-2c" ``` * The following JSON input performs the same filtering. ``` aws ec2 describe-instances --filters file://filters.json ``` filters.json: ```json [ { "Name": "instance-type", "Values": ["m1.small", "m1.medium"] }, { "Name": "availability-zone", "Values": ["us-west-2c"] } ] ``` ## Using jq (https://github.com/mwilliamson/jq.py) ``` aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.LaunchTime > "2015-01-28") | select(.State.Code != 48) | [.LaunchTime, .State.Name, (.Tags[]|select(.Key=="Name")|.Value)]' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | { KeyName, PublicIpAddress}' ``` -
carlessanagustin renamed this gist
Jun 6, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
carlessanagustin revised this gist
Jun 6, 2016 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,8 +2,10 @@ (http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html) * To describe all instances with the key-name type MyKey ``` aws ec2 describe-instances --output json --filters "Name=key-name,Values=MyKey" ``` * To describe all instances with a Owner tag -
carlessanagustin renamed this gist
Jun 6, 2016 . 1 changed file with 14 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,24 @@ ## Via AWS CLI filters (http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html) ``` aws ec2 describe-instances --output json --filters "Name=key-name,Values=lps-bigger-eurecat" ``` * To describe all instances with a Owner tag ``` aws ec2 describe-instances --filters "Name=tag-key,Values=Owner" ``` * To describe all instances with a Purpose=test tag ``` aws ec2 describe-instances --filters "Name=tag:Purpose,Values=test" ``` ## Using jq (https://github.com/mwilliamson/jq.py) -
carlessanagustin created this gist
Jun 6, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ ## Via AWS CLI: (http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html) ``` aws ec2 describe-instances --output json --filters "Name=key-name,Values=lps-bigger-eurecat" ``` ## Using jq: (https://github.com/mwilliamson/jq.py) ``` aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.LaunchTime > "2015-01-28") | select(.State.Code != 48) | [.LaunchTime, .State.Name, (.Tags[]|select(.Key=="Name")|.Value)]' aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.KeyName == "MyKey") | { KeyName, PublicIpAddress}' ```