It seems that there is no way to query ec2 instances via multiple tag-key filters that have AND logic since filters is a dict and include_filters treats all variations as OR conditions.
Issue Type
Bug Report
Component Name
amazon.aws.aws_ec2
Ansible Version
ansible [core 2.14.2]
Collection Versions
Collection Version
---------- -------
amazon.aws 5.1.0
plugin: amazon.aws.aws_ec2
hostnames:
- tag:Name
filters:
# Applies as OR logic
# Because filters is a dict can't specify multiple separate tag-key filters
tag-key:
- Role
- Team
plugin: amazon.aws.aws_ec2
hostnames:
- tag:Name
include_filters:
# Applies as OR logic
- tag-key: Role
- tag-key: Team
plugin: amazon.aws.aws_ec2
hostnames:
- tag:Name
include_filters:
# Also applies as OR logic
- tag-key:
- Role
- Team
Expected Results
That there is a way to apply AND logic for multiple tag keys as per the aws command below:
Both the filters version and include_filters return instances that have either the tag Role defined or Team defined, but not explicitly the ones that only have both.
Summary
It seems that there is no way to query ec2 instances via multiple tag-key filters that have AND logic since
filters
is a dict andinclude_filters
treats all variations as OR conditions.Issue Type
Bug Report
Component Name
amazon.aws.aws_ec2
Ansible Version
Collection Versions
AWS SDK versions
Configuration
No response
OS / Environment
No response
Steps to Reproduce
Expected Results
That there is a way to apply AND logic for multiple tag keys as per the aws command below:
This is in line with the AWS documentation which says that multiple filters with the same name are treated with the AND condition:
https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options
Actual Results
Both the
filters
version andinclude_filters
return instances that have either the tag Role defined or Team defined, but not explicitly the ones that only have both.Code of Conduct