-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tags argument into aws lb data source #12265
Comments
When will be available this feature? |
I would be very interested in helping getting this done if @mbyrdziak does not have time. |
We absolutely need this to get the ARN of a LB created by Kubernetes and to create a VPC link (for API Gateway) that points to that LB... |
any update on this? |
We also need this very urgently |
I found a workaround: data "kubernetes_service" "nginx-ingress" {
metadata {
namespace = "ingress-nginx"
name = "ingress-nginx-controller"
}
}
data "aws_lb" "ingress_nlb" {
name = regex("^(?P<name>.+)-.+\\.elb\\..+\\.amazonaws\\.com", data.kubernetes_service.nginx-ingress.load_balancer_ingress[0].hostname)["name"]
depends_on = [module.eks]
} It's a bit ugly bug seems to work |
@hameno
|
@jasgeo75 Are you sure? Do you have more than one NLB/ALB? The official documentation also does not suggest, that tags are supported: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lb As soon as I had more than one NLB the resource errors out with: |
@hameno Odd that this feature never materialized, in fact there is a PR: https://github.com/terraform-providers/terraform-provider-aws/pull/6458/files but looks like it was ignored. For now at least, your suggestion above seems the only solution. |
for those who uses kubernetes terraform provider version 2.x, the @hameno suggestion will look like data "kubernetes_service" "nginx-ingress" {
metadata {
namespace = "ingress-nginx"
name = "ingress-nginx-controller"
}
}
data "aws_lb" "ingress_nlb" {
name = regex("^(?P<name>.+)-.+\\.elb\\..+\\.amazonaws\\.com", data.kubernetes_service.nginx-ingress.status[0].load_balancer[0].ingress[0].hostname)["name"]
} |
Very important to be able to search by tag name, following |
Another workaround is introduced in AWS terraform provider release 3.38.0 data "aws_resourcegroupstaggingapi_resources" "load_balancer" {
resource_type_filters = ["elasticloadbalancing:loadbalancer"]
tag_filter {
key = "environment"
values = ["integration"]
}
tag_filter {
key = "owner"
values = ["my-company"]
}
}
data "aws_lb" "nlb" {
arn = data.aws_resourcegroupstaggingapi_resources.load_balancer.resource_tag_mapping_list[0].resource_arn
} |
Thank you for suggesting this. Though I kept getting this error:
I wanted to retrieve the DNS name of the ELB and a little bit of modification has worked for me: 👇
|
This functionality has been released in v3.52.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
Description
This is a feature request to ask for adding the "tags" argument into aws lb data source.
Quoting exactly from @mbyrdziak in #6458:
There is already a PR for this, but I'm creating an issue as it seems that this PR is lost in the wild without an issue to track this.
New or Affected Resource(s)
Potential Terraform Configuration
References
The text was updated successfully, but these errors were encountered: