amazon-web-services - 在 describe-vpcs 中按标签过滤的正确语法是什么?

标签 amazon-web-services amazon-ec2 amazon-vpc aws-cli

我正在尝试了解 aws ec2 cli 调用。我希望在自定义标签上描述所有 VPC,然后是文件管理器(vpcname=myvpc,但是在尝试多种组合后,我不断收到有关 --filters 的格式和使用的冲突错误。用作引用 [http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-vpcs.html][1]

aws --profile myProfile --region eu-west-1 ec2 describe-vpcs --filters vpcname,myvpc



但是这会返回
Error parsing parameter '--filters': should be: Key value pairs, where values are separated by commas, and multiple pairs are separated by spaces.
--filters Name=string1,Values=string1,string2 Name=string1,Values=string1,string2

如此努力

aws --profile myProfile --region eu-west-1 ec2 describe-vpcs --filters Name=vpcname,Values=myvpc



它返回
A client error (InvalidParameterValue) occurred when calling the DescribeVpcs operation: The filter 'vpcname' is invalid

所以尝试其他一些组合
aws --profile myProfile --region eu-west-1 ec2 describe-vpcs --filters tag :Name=vpcname,Values=myvpc

Error parsing parameter '--filters': should be: Key value pairs, where values are separated by commas, and multiple pairs are separated by spaces.
--filters Name=string1,Values=string1,string2 Name=string1,Values=string1,string2

关于如何格式化此请求的任何建议?

最佳答案

你已经很接近解决它了——唯一的问题是你没有指定 valid filter for describe-vpcs .这是与您的用例相关的过滤器:

tag:key=*value* - The key/value combination of a tag assigned to the resource.

所以当它要求Name=string1,Values=string1... ,它期望:
  • 名称=标签:标签名称
  • 值=标签值

  • 试试这个,使用不同的自定义标签在本地为我工作:
    aws ec2 describe-vpcs --filters Name=tag:vpcname,Values=myvpc
    

    关于amazon-web-services - 在 describe-vpcs 中按标签过滤的正确语法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27057932/

    相关文章:

    amazon-web-services - AWS KeyConditionExpression dynamodb 查询

    java - Amazon SWF 并行子工作流执行停止父工作流

    java - 在亚马逊云的 glassfish 服务器上部署 ear 时出现异常

    amazon-web-services - 从对等 VPC 连接到 Elasticache Redis 集群

    amazon-web-services - 从 Elastic Beanstalk 应用程序公开由 lambda 函数创建的文件

    amazon-web-services - 使用亚马逊通知服务发送带有自定义发件人 ID 的短信

    amazon-web-services - 如何使用 AWS EC2 实例 (Ubuntu AMI) 安装第三方 SSL 证书?是一次性收费还是按月收费?

    php - 如何将 opencart 与亚马逊 CDN 集成?

    amazon-web-services - 云形成 : unable to recreate EC2 instance with the same ElasticIp

    amazon-web-services - 如何确定 AWS 中的子网 IPv4 CIDR 地址?