/
subscribed_rule_groups.go
72 lines (67 loc) · 2.3 KB
/
subscribed_rule_groups.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package waf
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/waf"
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
"github.com/cloudquery/cq-provider-sdk/provider/diag"
"github.com/cloudquery/cq-provider-sdk/provider/schema"
)
func WafSubscribedRuleGroups() *schema.Table {
return &schema.Table{
Name: "aws_waf_subscribed_rule_groups",
Description: "This is AWS WAF Classic documentation",
Resolver: fetchWafSubscribedRuleGroups,
Multiplex: client.AccountMultiplex,
IgnoreError: client.IgnoreCommonErrors,
DeleteFilter: client.DeleteAccountFilter,
IgnoreInTests: true,
Options: schema.TableCreationOptions{PrimaryKeys: []string{"account_id", "rule_group_id"}},
Columns: []schema.Column{
{
Name: "account_id",
Description: "The AWS Account ID of the resource.",
Type: schema.TypeString,
Resolver: client.ResolveAWSAccount,
},
{
Name: "metric_name",
Description: "A friendly name or description for the metrics for this RuleGroup",
Type: schema.TypeString,
},
{
Name: "name",
Description: "A friendly name or description of the RuleGroup",
Type: schema.TypeString,
},
{
Name: "rule_group_id",
Description: "A unique identifier for a RuleGroup.",
Type: schema.TypeString,
},
},
}
}
// ====================================================================================================================
// Table Resolver Functions
// ====================================================================================================================
func fetchWafSubscribedRuleGroups(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
c := meta.(*client.Client)
service := c.Services().Waf
config := waf.ListSubscribedRuleGroupsInput{}
for {
output, err := service.ListSubscribedRuleGroups(ctx, &config, func(options *waf.Options) {
// Set region to default global region
options.Region = "us-east-1"
})
if err != nil {
return diag.WrapError(err)
}
res <- output.RuleGroups
if aws.ToString(output.NextMarker) == "" {
break
}
config.NextMarker = output.NextMarker
}
return nil
}