Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,16 @@ func TestCollectorCollectsAllRecordTypesAndAccumulatesErrors(t *testing.T) {
if th.Input.Config["target_id"] != "i-1234567890abcdef0" || th.Input.Config["target_health_state"] != "healthy" {
t.Fatalf("target health config = %#v", th.Input.Config)
}
if th.Labels["target_id"] != "i-1234567890abcdef0" {
t.Fatalf("target health labels missing target_id: %#v", th.Labels)
}
for _, typ := range []string{resourceTypeLoadBalancer, resourceTypeListener, resourceTypeTargetGroup} {
for _, record := range byType[typ] {
if _, ok := record.Labels["target_id"]; ok {
t.Fatalf("%s labels should not contain target_id: %#v", typ, record.Labels)
}
}
}

var sawHealthError bool
for _, record := range result.Records {
Expand Down
4 changes: 4 additions & 0 deletions input.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ func newTargetHealthRecord(account AccountContext, region string, targetGroupARN
"target_health_state": state,
}
record := newResourceRecord(account, region, ResourceIdentity{ID: id, ARN: targetGroupARN, Type: resourceTypeTargetHealth}, config, nil, nil, errors, policyInputs, collectedAt, nil, targetHealth, "aws-elbv2-target-health", fmt.Sprintf("aws-elbv2-target-health/%s/%s/%s", account.AccountID, region, id), "AWS ELBv2 Target Health ["+id+"]")
// target_id is exposed as a label so downstream evidence-search consumers can
// disambiguate targets sharing a target-group ARN; the resource_arn/resource_id
// labels alone are not sufficient for exact-match filtering.
record.Labels["target_id"] = targetID
return &record
}

Expand Down
Loading