@@ -14,11 +14,12 @@ import (
1414func Policies () * schema.Table {
1515 tableName := "aws_iot_policies"
1616 return & schema.Table {
17- Name : tableName ,
18- Description : `https://docs.aws.amazon.com/iot/latest/apireference/API_Policy.html` ,
19- Resolver : fetchIotPolicies ,
20- Transform : transformers .TransformWithStruct (& types.Policy {}),
21- Multiplex : client .ServiceAccountRegionMultiplexer (tableName , "iot" ),
17+ Name : tableName ,
18+ Description : `https://docs.aws.amazon.com/iot/latest/apireference/API_Policy.html` ,
19+ Resolver : fetchIotPolicies ,
20+ PreResourceResolver : getPolicy ,
21+ Transform : transformers .TransformWithStruct (& types.Policy {}),
22+ Multiplex : client .ServiceAccountRegionMultiplexer (tableName , "iot" ),
2223 Columns : []schema.Column {
2324 client .DefaultAccountIDColumn (false ),
2425 client .DefaultRegionColumn (false ),
@@ -52,22 +53,25 @@ func fetchIotPolicies(ctx context.Context, meta schema.ClientMeta, parent *schem
5253 if err != nil {
5354 return err
5455 }
56+ res <- page .Policies
57+ }
58+ return nil
59+ }
5560
56- for _ , s := range page .Policies {
57- // TODO: Handle resolution in parallel with PreResourceResolver
58- profile , err := svc .GetPolicy (ctx , & iot.GetPolicyInput {
59- PolicyName : s .PolicyName ,
60- }, func (options * iot.Options ) {
61- options .Region = cl .Region
62- })
63- if err != nil {
64- return err
65- }
66- res <- profile
67- }
61+ func getPolicy (ctx context.Context , meta schema.ClientMeta , resource * schema.Resource ) error {
62+ cl := meta .(* client.Client )
63+ svc := cl .Services ().Iot
64+
65+ output , err := svc .GetPolicy (ctx , & iot.GetPolicyInput {
66+ PolicyName : resource .Item .(types.Policy ).PolicyName ,
67+ })
68+ if err != nil {
69+ return err
6870 }
71+ resource .Item = output
6972 return nil
7073}
74+
7175func ResolveIotPolicyTags (ctx context.Context , meta schema.ClientMeta , resource * schema.Resource , c schema.Column ) error {
7276 i := resource .Item .(* iot.GetPolicyOutput )
7377 svc := meta .(* client.Client ).Services ().Iot
0 commit comments