/
subnet_groups_fetch.go
36 lines (32 loc) · 1.02 KB
/
subnet_groups_fetch.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package redshift
import (
"context"
"fmt"
"github.com/OpsHelmInc/cloudquery/client"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/redshift"
"github.com/aws/aws-sdk-go-v2/service/redshift/types"
"github.com/cloudquery/plugin-sdk/schema"
)
func fetchRedshiftSubnetGroups(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
var config redshift.DescribeClusterSubnetGroupsInput
c := meta.(*client.Client)
svc := c.Services().Redshift
for {
response, err := svc.DescribeClusterSubnetGroups(ctx, &config)
if err != nil {
return err
}
res <- response.ClusterSubnetGroups
if aws.ToString(response.Marker) == "" {
break
}
config.Marker = response.Marker
}
return nil
}
func resolveSubnetGroupArn() schema.ColumnResolver {
return client.ResolveARN(client.RedshiftService, func(resource *schema.Resource) ([]string, error) {
return []string{fmt.Sprintf("subnetgroup:%s", *resource.Item.(types.ClusterSubnetGroup).ClusterSubnetGroupName)}, nil
})
}