-
Notifications
You must be signed in to change notification settings - Fork 0
/
resource_share_associations_fetch.go
42 lines (37 loc) · 1.31 KB
/
resource_share_associations_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
package ram
import (
"context"
"github.com/OpsHelmInc/cloudquery/client"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ram"
"github.com/aws/aws-sdk-go-v2/service/ram/types"
"github.com/cloudquery/plugin-sdk/schema"
)
func fetchRamResourceShareAssociations(ctx context.Context, meta schema.ClientMeta, _ *schema.Resource, res chan<- any) error {
err := fetchRamResourceShareAssociationsByType(ctx, meta, &ram.GetResourceShareAssociationsInput{
AssociationType: types.ResourceShareAssociationTypeResource,
MaxResults: aws.Int32(500),
}, res)
if err != nil {
return err
}
err = fetchRamResourceShareAssociationsByType(ctx, meta, &ram.GetResourceShareAssociationsInput{
AssociationType: types.ResourceShareAssociationTypePrincipal,
MaxResults: aws.Int32(500),
}, res)
if err != nil {
return err
}
return nil
}
func fetchRamResourceShareAssociationsByType(ctx context.Context, meta schema.ClientMeta, resourceShareInput *ram.GetResourceShareAssociationsInput, res chan<- any) error {
paginator := ram.NewGetResourceShareAssociationsPaginator(meta.(*client.Client).Services().Ram, resourceShareInput)
for paginator.HasMorePages() {
response, err := paginator.NextPage(ctx)
if err != nil {
return err
}
res <- response.ResourceShareAssociations
}
return nil
}