Skip to content
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

Find aws_lb by tags in data source #6458

Merged
merged 3 commits into from
Jul 23, 2021

Conversation

mbyrdziak
Copy link

@mbyrdziak mbyrdziak commented Nov 14, 2018

Closes #12265.

Changes proposed in this pull request:

  • Add tags argument into aws lb data source (some tools, like kubernetes, creates cloud resources with random names hence you are unable to find them by current possibilities of this data source. Finding load balancers by specifying tags will solve this issue)

Output from acceptance testing:

$make testacc TESTARGS='-run="TestAccDataSourceAWSLB_basic|TestAccDataSourceAWSLBBackwardsCompatibility"'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run="TestAccDataSourceAWSLB_basic|TestAccDataSourceAWSLBBackwardsCompatibility" -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccDataSourceAWSLB_basic
=== PAUSE TestAccDataSourceAWSLB_basic
=== RUN   TestAccDataSourceAWSLBBackwardsCompatibility
=== PAUSE TestAccDataSourceAWSLBBackwardsCompatibility
=== CONT  TestAccDataSourceAWSLB_basic
=== CONT  TestAccDataSourceAWSLBBackwardsCompatibility
--- PASS: TestAccDataSourceAWSLBBackwardsCompatibility (244.02s)
--- PASS: TestAccDataSourceAWSLB_basic (255.54s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	255.558s

...

@ghost ghost added size/M Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/elbv2 Issues and PRs that pertain to the elbv2 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Nov 14, 2018
@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Nov 15, 2018
@mbyrdziak
Copy link
Author

@bflad Have a moment to take a look at this enhancement and give some feedback if this have a chance to be merged soon? Thanks in advance.

@mbyrdziak
Copy link
Author

@bflad Any chance to review and merge this? I would like to remove custom provider in our provision process. Thanks!

@mbyrdziak
Copy link
Author

@ewbankkit Hey, could you find time to review this? It would be a great simplification for our stack.

@aeschright aeschright requested a review from a team June 25, 2019 21:37
@sebolabs
Copy link

any chance to resurrect this? this enhancement would be very useful

@MaxFlanders
Copy link

Would love to see this get added!

@ofirshtrull
Copy link

would also like to see this go in, now I have my k8s cluster create load balancers so I need to have a way to connect to terraform via tag only because the k8s creates lbs with wired names

@ofirshtrull
Copy link

ofirshtrull commented Sep 10, 2020

@mbyrdziak is there a chance to maybe fix the conflicts and find someone to approve it?
@bflad maybe you can help to add this to the next release?

@wambozi
Copy link

wambozi commented Oct 13, 2020

would also like to see this go in, now I have my k8s cluster create load balancers so I need to have a way to connect to terraform via tag only because the k8s creates lbs with wired names

@ofirshtrull you can use the kubernetes provider to get the load balancers, if waiting for this is holding you up. e.g.

terraform {
  required_version = ">= 0.12"
  backend "s3" {}
}

// instantiating an empty kubernetes provider will pick up your kube config from 
// ~/.kube/config. Works out well for local dev and pipelines.
provider "kubernetes" {}

provider "aws" {
  version = "~>2.0"
  region  = "us-east-1"
}

variable "service_name" {
    description = "name of the service in kubernetes"
    type = string
}

data "kubernetes_service" "_" {
  metadata {
    name      = "${var.service_name}-nlb"
    namespace = var.kubernetes_namespace
  }
}

data "aws_lb" "_" {
  name = split("-", "${data.kubernetes_service._.load_balancer_ingress.0.hostname}")[0]
}

@ofirshtrull
Copy link

thanks @wambozi but it dosnet help i tried this with

data "kubernetes_ingress" "example" {
  metadata {
    name = "foo.bar.com"
    namespace = "develop"
  }
}

but i am getting errors that it cannot find the ingress
such as Error: Failed to read Ingress '/' because: ingresses.extensions "foo.bar.com" not found

@stibi
Copy link

stibi commented Oct 21, 2020

Hello, is there anything I can help with to get this merged?

@AndrewChubatiuk
Copy link

Any progress on it?

@ofirshtrull
Copy link

@antonbabenko maybe you can help move this forward?

@antonbabenko
Copy link
Contributor

I wish I can do anything related to the processing speed of the pull-request but I can't.

@ckdarby
Copy link

ckdarby commented Dec 8, 2020

@BrunoChauvet Any idea what is blocking this from being merged and moving forward?

@ckdarby
Copy link

ckdarby commented Dec 9, 2020

@gdavison Any idea what is blocking this from being merged and moving forward?

Just noticed that @BrunoChauvet doesn't work at HashiCorp.

Base automatically changed from master to main January 23, 2021 00:55
@breathingdust breathingdust requested a review from a team as a code owner January 23, 2021 00:55
@YakDriver YakDriver changed the title Add tags argument into aws lb data source Find aws_lb by tags in data source Jul 13, 2021
@ewbankkit ewbankkit force-pushed the feature/data-aws-lb-with-tags branch from c86fb76 to 0fde831 Compare July 23, 2021 18:23
@github-actions github-actions bot added size/L Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Jul 23, 2021
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

Commercial
% make testacc TESTARGS='-run=TestAccDataSourceAWSLB_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccDataSourceAWSLB_ -timeout 180m
=== RUN   TestAccDataSourceAWSLB_basic
=== PAUSE TestAccDataSourceAWSLB_basic
=== RUN   TestAccDataSourceAWSLB_outpost
=== PAUSE TestAccDataSourceAWSLB_outpost
=== RUN   TestAccDataSourceAWSLB_BackwardsCompatibility
=== PAUSE TestAccDataSourceAWSLB_BackwardsCompatibility
=== CONT  TestAccDataSourceAWSLB_basic
=== CONT  TestAccDataSourceAWSLB_BackwardsCompatibility
=== CONT  TestAccDataSourceAWSLB_outpost
    data_source_aws_outposts_outposts_test.go:67: skipping since no Outposts found
--- SKIP: TestAccDataSourceAWSLB_outpost (1.89s)
--- PASS: TestAccDataSourceAWSLB_basic (244.75s)
--- PASS: TestAccDataSourceAWSLB_BackwardsCompatibility (249.19s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	252.614s
GovCloud
% make testacc TESTARGS='-run=TestAccDataSourceAWSLB_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccDataSourceAWSLB_ -timeout 180m
=== RUN   TestAccDataSourceAWSLB_basic
=== PAUSE TestAccDataSourceAWSLB_basic
=== RUN   TestAccDataSourceAWSLB_outpost
=== PAUSE TestAccDataSourceAWSLB_outpost
=== RUN   TestAccDataSourceAWSLB_BackwardsCompatibility
=== PAUSE TestAccDataSourceAWSLB_BackwardsCompatibility
=== CONT  TestAccDataSourceAWSLB_basic
=== CONT  TestAccDataSourceAWSLB_BackwardsCompatibility
=== CONT  TestAccDataSourceAWSLB_outpost
    data_source_aws_outposts_outposts_test.go:67: skipping since no Outposts found
--- SKIP: TestAccDataSourceAWSLB_outpost (2.20s)
--- PASS: TestAccDataSourceAWSLB_BackwardsCompatibility (224.70s)
--- PASS: TestAccDataSourceAWSLB_basic (234.57s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	239.327s

@ewbankkit
Copy link
Contributor

@mbyrdziak Thanks for the contribution 🎉 👏.
To get this merged more quickly I went ahead and pushed a couple of changes, most significantly using keyvaluetags.ContainsAll instead of reflect to do the filtering.

@ewbankkit ewbankkit merged commit 116ff2a into hashicorp:main Jul 23, 2021
@github-actions github-actions bot added this to the v3.52.0 milestone Jul 23, 2021
@github-actions
Copy link

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!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/elbv2 Issues and PRs that pertain to the elbv2 service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tags argument into aws lb data source