Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Last active March 30, 2017 01:11
Show Gist options
  • Save tkuchiki/576abbb94e398b7ee6553deee0b632ea to your computer and use it in GitHub Desktop.
Save tkuchiki/576abbb94e398b7ee6553deee0b632ea to your computer and use it in GitHub Desktop.
aws ec2 describe-instances で特定文字列が含まれる Nameタグがついたインスタンスを出力する

Nameタグが test- で始まりステータスが running のインスタンスを出力する

$ aws ec2 describe-instances --filters "Name=instance-state-code,Values=16" "Name=tag:Name,Values=test-*" | less | jq .Reservatio
ns[].Instances[]
{
  "Monitoring": {
...
}

Name タグが test- で始まりステータスが running のインスタンスの Name タグを出力する

$ aws ec2 describe-instances --filters "Name=instance-state-code,Values=16" "Name=tag:Name,Values=test-*" | jq -r '.Reservations[
].Instances[].Tags[] | select(.Key == "Name").Value
test-web01
test-web02
test-app01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment