/
region_settings.go
63 lines (57 loc) · 2.14 KB
/
region_settings.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
package backup
import (
"context"
"github.com/aws/aws-sdk-go-v2/service/backup"
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
"github.com/cloudquery/cq-provider-sdk/provider/diag"
"github.com/cloudquery/cq-provider-sdk/provider/schema"
)
//go:generate cq-gen --resource region_settings --config gen.hcl --output .
func RegionSettings() *schema.Table {
return &schema.Table{
Name: "aws_backup_region_settings",
Resolver: fetchBackupRegionSettings,
Multiplex: client.ServiceAccountRegionMultiplexer("backup"),
IgnoreError: client.IgnoreCommonErrors,
DeleteFilter: client.DeleteAccountRegionFilter,
Options: schema.TableCreationOptions{PrimaryKeys: []string{"account_id", "region"}},
Columns: []schema.Column{
{
Name: "account_id",
Description: "The AWS Account ID of the resource.",
Type: schema.TypeString,
Resolver: client.ResolveAWSAccount,
},
{
Name: "region",
Description: "The AWS Region of the resource.",
Type: schema.TypeString,
Resolver: client.ResolveAWSRegion,
},
{
Name: "resource_type_management_preference",
Description: "Returns whether Backup fully manages the backups for a resource type",
Type: schema.TypeJSON,
},
{
Name: "resource_type_opt_in_preference",
Description: "Returns a list of all services along with the opt-in preferences in the Region.",
Type: schema.TypeJSON,
},
},
}
}
// ====================================================================================================================
// Table Resolver Functions
// ====================================================================================================================
func fetchBackupRegionSettings(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
c := meta.(*client.Client)
svc := c.Services().Backup
input := backup.DescribeRegionSettingsInput{}
output, err := svc.DescribeRegionSettings(ctx, &input)
if err != nil {
return diag.WrapError(err)
}
res <- output
return nil
}