@@ -3,12 +3,11 @@ package elbv1
33import (
44 "context"
55
6- "github.com/OpsHelmInc/cloudquery/client"
7- "github.com/OpsHelmInc/cloudquery/resources/services/elbv1/models"
8- "github.com/aws/aws-sdk-go-v2/aws"
96 elbv1 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing"
107 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/types"
118 "github.com/cloudquery/plugin-sdk/schema"
9+
10+ "github.com/OpsHelmInc/cloudquery/client"
1211)
1312
1413func fetchElbv1LoadBalancers (ctx context.Context , meta schema.ClientMeta , parent * schema.Resource , res chan <- any ) error {
@@ -19,20 +18,24 @@ func fetchElbv1LoadBalancers(ctx context.Context, meta schema.ClientMeta, parent
1918 for _ , lb := range loadBalancers {
2019 tagsCfg .LoadBalancerNames = append (tagsCfg .LoadBalancerNames , * lb .LoadBalancerName )
2120 }
22- tagsResponse , err := svc .DescribeTags (ctx , tagsCfg )
21+ tagsResponse , err := svc .DescribeTags (ctx , tagsCfg , func (options * elbv1.Options ) {
22+ options .Region = c .Region
23+ })
2324 if err != nil {
2425 return err
2526 }
2627 for _ , lb := range loadBalancers {
27- loadBalancerAttributes , err := svc .DescribeLoadBalancerAttributes (ctx , & elbv1.DescribeLoadBalancerAttributesInput {LoadBalancerName : lb .LoadBalancerName })
28+ loadBalancerAttributes , err := svc .DescribeLoadBalancerAttributes (ctx , & elbv1.DescribeLoadBalancerAttributesInput {LoadBalancerName : lb .LoadBalancerName }, func (options * elbv1.Options ) {
29+ options .Region = c .Region
30+ })
2831 if err != nil {
2932 if c .IsNotFoundError (err ) {
3033 continue
3134 }
3235 return err
3336 }
3437
35- wrapper := models. ELBv1LoadBalancerWrapper {
38+ wrapper := ohaws. LoadBalancerV1 {
3639 LoadBalancerDescription : lb ,
3740 Tags : client .TagsToMap (getTagsByLoadBalancerName (* lb .LoadBalancerName , tagsResponse .TagDescriptions )),
3841 Attributes : loadBalancerAttributes .LoadBalancerAttributes ,
@@ -42,37 +45,33 @@ func fetchElbv1LoadBalancers(ctx context.Context, meta schema.ClientMeta, parent
4245 }
4346 return nil
4447 }
45-
46- var config elbv1.DescribeLoadBalancersInput
47- for {
48- response , err := svc .DescribeLoadBalancers (ctx , & config )
48+ paginator := elbv1 .NewDescribeLoadBalancersPaginator (svc , & elbv1.DescribeLoadBalancersInput {})
49+ for paginator .HasMorePages () {
50+ page , err := paginator .NextPage (ctx , func (options * elbv1.Options ) {
51+ options .Region = c .Region
52+ })
4953 if err != nil {
5054 return err
5155 }
5256
53- for i := 0 ; i < len (response .LoadBalancerDescriptions ); i += 20 {
57+ for i := 0 ; i < len (page .LoadBalancerDescriptions ); i += 20 {
5458 end := i + 20
5559
56- if end > len (response .LoadBalancerDescriptions ) {
57- end = len (response .LoadBalancerDescriptions )
60+ if end > len (page .LoadBalancerDescriptions ) {
61+ end = len (page .LoadBalancerDescriptions )
5862 }
59- loadBalancers := response .LoadBalancerDescriptions [i :end ]
63+ loadBalancers := page .LoadBalancerDescriptions [i :end ]
6064 if err := processLoadBalancers (loadBalancers ); err != nil {
6165 return err
6266 }
6367 }
64-
65- if aws .ToString (response .NextMarker ) == "" {
66- break
67- }
68- config .Marker = response .NextMarker
6968 }
7069
7170 return nil
7271}
7372
7473func fetchElbv1LoadBalancerPolicies (ctx context.Context , meta schema.ClientMeta , parent * schema.Resource , res chan <- any ) error {
75- r := parent .Item .(models. ELBv1LoadBalancerWrapper )
74+ r := parent .Item .(ohaws. LoadBalancerV1 )
7675 c := meta .(* client.Client )
7776 svc := c .Services ().Elasticloadbalancing
7877 response , err := svc .DescribeLoadBalancerPolicies (ctx , & elbv1.DescribeLoadBalancerPoliciesInput {LoadBalancerName : r .LoadBalancerName })
@@ -82,6 +81,7 @@ func fetchElbv1LoadBalancerPolicies(ctx context.Context, meta schema.ClientMeta,
8281 res <- response .PolicyDescriptions
8382 return nil
8483}
84+
8585func resolveElbv1loadBalancerPolicyAttributeDescriptions (ctx context.Context , meta schema.ClientMeta , resource * schema.Resource , c schema.Column ) error {
8686 r := resource .Item .(types.PolicyDescription )
8787
@@ -103,6 +103,6 @@ func getTagsByLoadBalancerName(id string, tagsResponse []types.TagDescription) [
103103
104104func resolveLoadBalancerARN () schema.ColumnResolver {
105105 return client .ResolveARN (client .ElasticLoadBalancingService , func (resource * schema.Resource ) ([]string , error ) {
106- return []string {"loadbalancer" , * resource .Item .(models. ELBv1LoadBalancerWrapper ).LoadBalancerName }, nil
106+ return []string {"loadbalancer" , * resource .Item .(ohaws. LoadBalancerV1 ).LoadBalancerName }, nil
107107 })
108108}
0 commit comments