```terraform -v
Terraform v0.11.13
### Affected Resource(s)
<!--- Please list the affected resources and data sources. --->
* data.aws_lb_target_group
### Terraform Configuration Files
<!--- Information about code formatting: https://help.github.com/articles/basic-writing-and-formatting-syntax/#quoting-code --->
```hcl
provider "aws" {
version = ">= 2.5.0"
}
data "aws_lb_target_group" "tg_names" {
name = "hb-monitoring-rest-tg"
}
provider "aws" {
version = "<= 2.4.0"
}
data "aws_lb_target_group" "tg_names" {
name = "hb-monitoring-rest-tg"
}
```terraform apply
data.aws_lb_target_group.tg_names: Refreshing state...
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
### Actual Behavior
<!--- What actually happened? --->
```terraform apply
data.aws_lb_target_group.tg_names: Refreshing state...
Error: Error refreshing state: 1 error(s) occurred:
* data.aws_lb_target_group.tg_names: 1 error(s) occurred:
* data.aws_lb_target_group.tg_names: data.aws_lb_target_group.tg_names: error setting health_check: Invalid address to set: []string{"health_check", "0", "enabled"}
Possibly this commit:
https://github.com/terraform-providers/terraform-provider-aws/commit/28697473830ec073885e38e32ef96528425090c2#diff-375aea487c27a6ada86edfd817ba2401
Yes, it looks like flattenAwsLbTargetGroupResource() which was updated in https://github.com/terraform-providers/terraform-provider-aws/pull/7570 is used in both the aws_lb_target_group resource and data source.
The schema for the resource was updated in the PR but not the schema for the data source.
The data source's acceptance tests are failing also:
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccDataSourceAWSALBTargetGroup_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -parallel 20 -run=TestAccDataSourceAWSALBTargetGroup_ -timeout 120m
=== RUN TestAccDataSourceAWSALBTargetGroup_basic
=== PAUSE TestAccDataSourceAWSALBTargetGroup_basic
=== CONT TestAccDataSourceAWSALBTargetGroup_basic
--- FAIL: TestAccDataSourceAWSALBTargetGroup_basic (170.42s)
testing.go:538: Step 0 error: Error applying: 2 errors occurred:
* data.aws_lb_target_group.alb_tg_test_with_arn: data.aws_lb_target_group.alb_tg_test_with_arn: error setting health_check: Invalid address to set: []string{"health_check", "0", "enabled"}
* data.aws_lb_target_group.alb_tg_test_with_name: data.aws_lb_target_group.alb_tg_test_with_name: error setting health_check: Invalid address to set: []string{"health_check", "0", "enabled"}
testing.go:599: Error destroying resource! WARNING: Dangling resources
may exist. The full state and error is shown below.
Error: Error refreshing: 2 errors occurred:
* data.aws_lb_target_group.alb_tg_test_with_arn: 1 error occurred:
* data.aws_lb_target_group.alb_tg_test_with_arn: data.aws_lb_target_group.alb_tg_test_with_arn: error setting health_check: Invalid address to set: []string{"health_check", "0", "enabled"}
* data.aws_lb_target_group.alb_tg_test_with_name: 1 error occurred:
* data.aws_lb_target_group.alb_tg_test_with_name: data.aws_lb_target_group.alb_tg_test_with_name: error setting health_check: Invalid address to set: []string{"health_check", "0", "enabled"}
State: <nil>
FAIL
FAIL github.com/terraform-providers/terraform-provider-aws/aws 170.443s
GNUmakefile:20: recipe for target 'testacc' failed
make: *** [testacc] Error 1
👍
The fix for this has been merged and will release with version 2.6.0 of the Terraform AWS Provider, early next week.
I am also struggling w/ this error.....
10:01:35 Error: Error refreshing state: 1 error(s) occurred:
10:01:35
10:01:35 * module.nlb.data.aws_lb_target_group.app_nlb_default_tg: 1 error(s) occurred:
10:01:35
10:01:35 * module.nlb.data.aws_lb_target_group.app_nlb_default_tg: data.aws_lb_target_group.app_nlb_default_tg: error setting health_check: Invalid address to set: []string{"health_check", "0", "enabled"}
So.. this IS a bug w/ Terraform AWS Provider 2.5.0? This was recently released last week. So.. 2.6.0 is coming out this week to fix?
The fix for this has been released in version 2.6.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
Thanks for this fix, just ran into this bug.
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.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!