55
66 "github.com/aws/aws-sdk-go-v2/aws"
77 "github.com/aws/aws-sdk-go-v2/service/iot"
8+ "github.com/aws/aws-sdk-go-v2/service/iot/types"
89 "github.com/cloudquery/cloudquery/plugins/source/aws/client"
910 "github.com/cloudquery/plugin-sdk/schema"
1011 "github.com/cloudquery/plugin-sdk/transformers"
@@ -13,11 +14,12 @@ import (
1314func ThingGroups () * schema.Table {
1415 tableName := "aws_iot_thing_groups"
1516 return & schema.Table {
16- Name : tableName ,
17- Description : `https://docs.aws.amazon.com/iot/latest/apireference/API_DescribeThingGroup.html` ,
18- Resolver : fetchIotThingGroups ,
19- Transform : transformers .TransformWithStruct (& iot.DescribeThingGroupOutput {}),
20- Multiplex : client .ServiceAccountRegionMultiplexer (tableName , "iot" ),
17+ Name : tableName ,
18+ Description : `https://docs.aws.amazon.com/iot/latest/apireference/API_DescribeThingGroup.html` ,
19+ Resolver : fetchIotThingGroups ,
20+ PreResourceResolver : getThingGroup ,
21+ Transform : transformers .TransformWithStruct (& iot.DescribeThingGroupOutput {}),
22+ Multiplex : client .ServiceAccountRegionMultiplexer (tableName , "iot" ),
2123 Columns : []schema.Column {
2224 client .DefaultAccountIDColumn (false ),
2325 client .DefaultRegionColumn (false ),
@@ -61,21 +63,25 @@ func fetchIotThingGroups(ctx context.Context, meta schema.ClientMeta, parent *sc
6163 if err != nil {
6264 return err
6365 }
64- for _ , g := range page .ThingGroups {
65- // TODO: Handle resolution in parallel with PreResourceResolver
66- group , err := svc .DescribeThingGroup (ctx , & iot.DescribeThingGroupInput {
67- ThingGroupName : g .GroupName ,
68- }, func (options * iot.Options ) {
69- options .Region = c .Region
70- })
71- if err != nil {
72- return err
73- }
74- res <- group
75- }
66+ res <- page .ThingGroups
7667 }
7768 return nil
7869}
70+
71+ func getThingGroup (ctx context.Context , meta schema.ClientMeta , resource * schema.Resource ) error {
72+ cl := meta .(* client.Client )
73+ svc := cl .Services ().Iot
74+
75+ output , err := svc .DescribeThingGroup (ctx , & iot.DescribeThingGroupInput {
76+ ThingGroupName : resource .Item .(types.GroupNameAndArn ).GroupName ,
77+ })
78+ if err != nil {
79+ return err
80+ }
81+ resource .Item = output
82+ return nil
83+ }
84+
7985func ResolveIotThingGroupThingsInGroup (ctx context.Context , meta schema.ClientMeta , resource * schema.Resource , c schema.Column ) error {
8086 i := resource .Item .(* iot.DescribeThingGroupOutput )
8187 cl := meta .(* client.Client )
0 commit comments