更正aws cli语法以在非默认VPC中查找VPC安全组

 王妮美的小姐姐 发布于 2022-12-09 18:19

这是一个后续问题,在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"中不存在

那么如何使用-filters列表(例如vpc-id)格式化语法以在非默认VPC中搜索安全组?

thx艺术

1 个回答
  • 文件说:

       --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和名称进行过滤:

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

    要根据特定的VPC和任何标记进行过滤:

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

    要根据特定的VPC和特定标记进行过滤:

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

    注意:标记名称和值区分大小写.

    2022-12-11 02:06 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有