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.85k stars 9.2k forks source link

[Bug]: aws_lb_target_group: "Error: Search returned 0 results, please revise so only one is returned" with existing resources #29512

Open ValeriiVozniuk opened 1 year ago

ValeriiVozniuk commented 1 year ago

Terraform Core Version

1.3.9

AWS Provider Version

4.50

Affected Resource(s)

aws_lb_target_group

Expected Behavior

Provider is able to find existing aws_lb_target_group resources without errors

Actual Behavior

Provider is not able to find aws_lb_target_group resources, see the error below

Relevant Error/Panic Output Snippet

│ Error: Search returned 0 results, please revise so only one is returned
│
│   with module.autoscaling-groups.data.aws_lb_target_group.aws_lb_target_group_asg["protected-alb-80-tg"],
│   on data_asg_templates.tf line 85, in data "aws_lb_target_group" "aws_lb_target_group_asg":
│   85: data "aws_lb_target_group" "aws_lb_target_group_asg" {

Terraform Configuration Files

-

Steps to Reproduce

Run terraform plan with plugin version 4.50+

Debug Output

good.txt fail.txt

Panic Output

No response

Important Factoids

The issue appeared in provider version 4.50, suspected cause is https://github.com/hashicorp/terraform-provider-aws/pull/27161 Attached traces from working plan command with plugin 4.49 and non-working plan for 4.50

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

cloud-mt commented 1 year ago

any update on this?

arashkevich25 commented 1 year ago

+1

lmbleandro commented 1 year ago

+1

jaybe78 commented 1 year ago

+1

devraj commented 11 months ago

Same here, we are using this in conjunction with EKS and have two clusters (hence two load balancers) and get the same issue:

➜  infrastructure git:(test) ✗ terraform -version     
Terraform v1.6.5
on darwin_arm64
+ provider registry.terraform.io/gavinbunney/kubectl v1.14.0
+ provider registry.terraform.io/hashicorp/aws v5.29.0
+ provider registry.terraform.io/hashicorp/helm v2.12.1
+ provider registry.terraform.io/hashicorp/kubernetes v2.24.0
+ provider registry.terraform.io/hashicorp/random v3.6.0
+ provider registry.terraform.io/hashicorp/tls v4.0.5
ramesh-kumarjha commented 8 months ago

same here we are using aws loadblancer module.ec2_module.aws_instance.ec2[0]: Refreshing state... [id=xxxxxxxxxx]

│ Error: Search returned 303 results, please revise so only one is returned

│ with module.createNewTg.data.aws_lb_target_group.main-tg,

│ on ../../../module/tg_module_v1/main.tf line 1, in data "aws_lb_target_group" "main-tg":

│ 1: data "aws_lb_target_group" "main-tg"{

vinujan59 commented 7 months ago

+1

would be great if we have another data source as aws_lb_target_groups