/
instances_fetch.go
47 lines (42 loc) · 1.31 KB
/
instances_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
37
38
39
40
41
42
43
44
45
46
47
package rds
import (
"context"
"github.com/OpsHelmInc/cloudquery/client"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/rds"
"github.com/aws/aws-sdk-go-v2/service/rds/types"
"github.com/cloudquery/plugin-sdk/schema"
)
func fetchRdsInstances(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
var config rds.DescribeDBInstancesInput
c := meta.(*client.Client)
svc := c.Services().Rds
for {
response, err := svc.DescribeDBInstances(ctx, &config)
if err != nil {
return err
}
res <- response.DBInstances
if aws.ToString(response.Marker) == "" {
break
}
config.Marker = response.Marker
}
return nil
}
func resolveRdsInstanceProcessorFeatures(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.DBInstance)
processorFeatures := map[string]*string{}
for _, t := range r.ProcessorFeatures {
processorFeatures[*t.Name] = t.Value
}
return resource.Set(c.Name, processorFeatures)
}
func resolveRdsInstanceTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.DBInstance)
tags := map[string]*string{}
for _, t := range r.TagList {
tags[*t.Key] = t.Value
}
return resource.Set(c.Name, tags)
}