diff --git a/pkg/deploy/lattice/target_group_manager.go b/pkg/deploy/lattice/target_group_manager.go index 9034c0fc..0838f594 100644 --- a/pkg/deploy/lattice/target_group_manager.go +++ b/pkg/deploy/lattice/target_group_manager.go @@ -11,7 +11,6 @@ import ( "github.com/aws/aws-sdk-go/service/vpclattice" pkg_aws "github.com/aws/aws-application-networking-k8s/pkg/aws" - "github.com/aws/aws-application-networking-k8s/pkg/config" model "github.com/aws/aws-application-networking-k8s/pkg/model/lattice" "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" "reflect" @@ -256,11 +255,7 @@ func (s *defaultTargetGroupManager) List(ctx context.Context) ([]tgListOutput, e if len(resp) == 0 { return nil, nil } - validTgs := utils.SliceFilter(resp, func(tg *vpclattice.TargetGroupSummary) bool { - return aws.StringValue(tg.VpcIdentifier) == config.VpcID && - aws.StringValue(tg.Type) == vpclattice.TargetGroupTypeIp - }) - tgArns := utils.SliceMap(validTgs, func(tg *vpclattice.TargetGroupSummary) string { + tgArns := utils.SliceMap(resp, func(tg *vpclattice.TargetGroupSummary) string { return aws.StringValue(tg.Arn) }) tgArnToTagsMap, err := s.cloud.Tagging().GetTagsForArns(ctx, tgArns) @@ -268,7 +263,7 @@ func (s *defaultTargetGroupManager) List(ctx context.Context) ([]tgListOutput, e if err != nil { return nil, err } - for _, tg := range validTgs { + for _, tg := range resp { tgList = append(tgList, tgListOutput{ tgSummary: tg, tags: tgArnToTagsMap[*tg.Arn], diff --git a/pkg/deploy/lattice/target_group_manager_test.go b/pkg/deploy/lattice/target_group_manager_test.go index bad05bb1..3798c54f 100644 --- a/pkg/deploy/lattice/target_group_manager_test.go +++ b/pkg/deploy/lattice/target_group_manager_test.go @@ -778,6 +778,8 @@ func Test_ListTG_TGsExist(t *testing.T) { id := "123456789" name1 := "test1" config.VpcID = "vpc-id" + externalVpc := "external-vpc-id" + config.ClusterName = "cluster-name" tgType := vpclattice.TargetGroupTypeIp tg1 := &vpclattice.TargetGroupSummary{ @@ -792,7 +794,7 @@ func Test_ListTG_TGsExist(t *testing.T) { Arn: &arn, Id: &id, Name: &name2, - VpcIdentifier: &config.VpcID, + VpcIdentifier: &externalVpc, Type: &tgType, } listTGOutput := []*vpclattice.TargetGroupSummary{tg1, tg2}