hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.71k stars 9.07k forks source link

Enable data source `aws_lb` to find `internal` and specific `load_balancer_type` #23255

Open nitrocode opened 2 years ago

nitrocode commented 2 years ago

Community Note

Description

Currently the data source aws_lb is limited to arg, name, and tags arguments.

The resource aws_lb have these additional inputs that would be helpful in the data source.

There are more but the above list would be sufficient for my use case. For now, I have to tag my load balancer with the above values in order to retrieve the arn dynamically with a data source.

New or Affected Resource(s)

Potential Terraform Configuration

data "aws_lb" "test" {
  internal = true

  load_balancer_type = "network"

  tags = {
    Team    = "sre"
    Service = "titan"
  }
}

References

github-actions[bot] commented 6 months ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

nitrocode commented 6 months ago

Here's a workaround.

We could use plural data source aws_lbs then use the singular data source for EVERY lb and find the internal and network ones. This would be painful.

The other alternative is to use something like cloud custodian, filter for all the internal load balancers, tag all of them with internal=true or similar. Then use another policy to tag all the network load balancers with type=network. Finally, we can use the aws_lb data source to find the internal network lbs using tags.

The right way would be to add the arguments directly to the singular and plural data sources, and then we can use golang to filter through each one to find internal or whatever type we're looking for.