无法筛选 AWS RDS 堆栈名称

Unable to filter on AWS RDS stack-name

为什么这不起作用?提取与我的 rds 实例一起列出的标签:

aws rds list-tags-for-resource --resource-name arn:aws:rds:eu-central-1:12345678901:db:pa1jyg4oc56mipf

{
    "TagList": [
        {
            "Value": "DatabaseRdsInstance",
            "Key": "aws:cloudformation:logical-id"
        },
        {
            "Value": "production-test-123",
            "Key": "aws:cloudformation:stack-name"
        },
        {
            "Value": "arn:aws:cloudformation:eu-central-1:12345678901:stack/production-test-123/1234abc-56f9-11e5-b10e-50d501fbb66e",
            "Key": "aws:cloudformation:stack-id"
        }
    ]
}

过滤其中一个标签失败:

aws rds describe-db-instances --filters Name="tag:aws:cloudformation:stack-name",Values=production-test-123
A client error (InvalidParameterValue) occurred when calling the DescribeDBInstances operation: Unrecognized filter name: tag:aws:cloudformation:stack-name

当我离开名称的 tag 部分时它也不起作用:

aws rds describe-db-instances --filters Name="aws:cloudformation:stack-name",Values="production-test-123"

A client error (InvalidParameterValue) occurred when calling the DescribeDBInstances operation: Unrecognized filter name: aws:cloudformation:stack-name

我在这里错过了什么?

According to the documentation 不幸的是,--filters 选项目前不受支持。

您将不得不在客户端对标签执行过滤。

您可以尝试使用 resourcegroupstaggingapi

而不是使用 list-tag-resources

aws resourcegroupstaggingapi get-resources --resource-type-filters rds:db --tag-filters Key=aws:cloudformation:stack-id,Values=arn:aws:cloudformation:eu-central-1:12345678901:stack/production-test-123/1234abc-56f9-11e5-b10e-50d501fbb66e。它应该工作