4

これはWhat is the correct syntax for filtering by tag in describe-vpcs?からの質問の続きです。.

提供された回答を使用し、http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-security-groups.htmlを参照します。

--filters (list)
One or more filters.
......
vpc-id - The ID of the VPC specified when the security group was created.

CLIリクエストを作成しました

aws --profile myProfile --region eu-west-1 ec2 describe-security-groups --group-name MyVpcSecGroup --filters Name=tag:vpc-id,Values=vpc-9xxxxxxx

ただし、エラーが発生します

セキュリティ グループ「MyVpcSecGroup」はデフォルト VPC「vpc-bxxxxxx」に存在しません

では、vpc-id などの --filters のリストを使用して、デフォルト以外の VPC でセキュリティ グループを検索する構文をフォーマットするにはどうすればよいでしょうか?

thxアート

4

2 に答える 2

7

ドキュメントには次のように記載されています。

   --group-names (list)
      [EC2-Classic, default VPC] One or more security group names.

そのため、--group-namesデフォルト以外の VPC では使用できないようです。

ただし、代替方法があります。

aws ec2 describe-security-groups --group-ids sg-xxxxxxxx
aws ec2 describe-security-groups --filters Name=group-name,Values=MyVpcSecGroup

特定のVPC と Nameに基づいてフィルタリングするには:

aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-11223344 Name=group-name,Values=MyVpcSecGroup

特定のVPC と任意の Tagに基づいてフィルタリングするには:

aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-11223344 Name=tag-value,Values=Production

特定のVPC と特定の Tagに基づいてフィルタリングするには:

aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-11223344 Name=tag:Environment,Values=Production

注: タグの名前と値は大文字と小文字が区別されます。

于 2014-11-25T10:46:56.390 に答える
2

特定のグループを探すときの方法は次のとおりです。

aws --profile myProfile ec2 describe-security-groups --region=AWS_REGION --filters "Name=vpc-id,Values=VPC_ID" --filters "Name=group-name,Values=NAMEOFSECGROUP"
于 2014-11-25T23:25:39.007 に答える