When performing a data lookup by tags on aws_lb, like below:
data "aws_lb" "shared_alb" {
tags = {
env = local.tags.env
region = local.tags.region
shard_id = local.tags.shard_id
}
}
It first downloads all load balancers, then it performs filtering by tags. The time it takes to download all load balancers grows with the number of load balancers. E.g For ~400 load balancers, it's taking 42 seconds:
module.this.module.alb_listener_rule.data.aws_lb.shared_alb: Still reading... [20s elapsed]
module.this.module.alb_listener_rule.data.aws_lb.shared_alb: Still reading... [30s elapsed]
module.this.module.alb_listener_rule.data.aws_lb.shared_alb: Still reading... [40s elapsed]
module.this.module.alb_listener_rule.data.aws_lb.shared_alb: Read complete after 42s [id=arn:aws:elasticloadbalancing:us-east-1:...]
Is there anyway to filter by tags first, then download only the relevant ones?
Attempted Solutions
To avoid the extra 42 seconds per terraform plan command, we are working around by filtering by name addition to tags, but this means we are restricted to using name instead of name_prefix when creating aws_lb.
Proposal
Is there anyway to filter by tags first, then download only the relevant ones?
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
Volunteering to Work on This Issue
If you are interested in working on this issue, please leave a comment.
If this would be your first contribution, please review the contribution guide.
Description
Terraform Version
Use Cases
When performing a data lookup by tags on
aws_lb
, like below:It first downloads all load balancers, then it performs filtering by
tags
. The time it takes to download all load balancers grows with the number of load balancers. E.g For ~400 load balancers, it's taking 42 seconds:Is there anyway to filter by
tags
first, then download only the relevant ones?Attempted Solutions
To avoid the extra 42 seconds per
terraform plan
command, we are working around by filtering byname
addition totags
, but this means we are restricted to usingname
instead ofname_prefix
when creatingaws_lb
.Proposal
Is there anyway to filter by
tags
first, then download only the relevant ones?Affected Resource(s) and/or Data Source(s)
No response
Potential Terraform Configuration
No response
References
No response
Would you like to implement a fix?
None