-
Notifications
You must be signed in to change notification settings - Fork 0
/
principals_fetch.go
39 lines (35 loc) · 1.06 KB
/
principals_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
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 fetchRamPrincipals(ctx context.Context, meta schema.ClientMeta, _ *schema.Resource, res chan<- any) error {
err := fetchRamPrincipalsByOwner(ctx, meta, types.ResourceOwnerSelf, res)
if err != nil {
return err
}
err = fetchRamPrincipalsByOwner(ctx, meta, types.ResourceOwnerOtherAccounts, res)
if err != nil {
return err
}
return nil
}
func fetchRamPrincipalsByOwner(ctx context.Context, meta schema.ClientMeta, shareType types.ResourceOwner, res chan<- any) error {
input := &ram.ListPrincipalsInput{
MaxResults: aws.Int32(500),
ResourceOwner: shareType,
}
paginator := ram.NewListPrincipalsPaginator(meta.(*client.Client).Services().Ram, input)
for paginator.HasMorePages() {
response, err := paginator.NextPage(ctx)
if err != nil {
return err
}
res <- response.Principals
}
return nil
}