Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

feat: Add support for resource groups #1396

Merged
merged 9 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/qldb"
"github.com/aws/aws-sdk-go-v2/service/rds"
"github.com/aws/aws-sdk-go-v2/service/redshift"
"github.com/aws/aws-sdk-go-v2/service/resourcegroups"
"github.com/aws/aws-sdk-go-v2/service/route53"
"github.com/aws/aws-sdk-go-v2/service/route53domains"
"github.com/aws/aws-sdk-go-v2/service/s3"
Expand Down Expand Up @@ -164,6 +165,7 @@ type Services struct {
QLDB QLDBClient
RDS RdsClient
Redshift RedshiftClient
ResourceGroups ResourceGroupsClient
Route53 Route53Client
Route53Domains Route53DomainsClient
S3 S3Client
Expand Down Expand Up @@ -661,6 +663,7 @@ func initServices(region string, c aws.Config) Services {
Organizations: organizations.NewFromConfig(awsCfg),
QLDB: qldb.NewFromConfig(awsCfg),
RDS: rds.NewFromConfig(awsCfg),
ResourceGroups: resourcegroups.NewFromConfig(awsCfg),
Redshift: redshift.NewFromConfig(awsCfg),
Route53: route53.NewFromConfig(awsCfg),
Route53Domains: route53domains.NewFromConfig(awsCfg),
Expand Down
116 changes: 116 additions & 0 deletions client/mocks/mock_resourcegroups.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions client/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/qldb"
"github.com/aws/aws-sdk-go-v2/service/rds"
"github.com/aws/aws-sdk-go-v2/service/redshift"
"github.com/aws/aws-sdk-go-v2/service/resourcegroups"
"github.com/aws/aws-sdk-go-v2/service/route53"
"github.com/aws/aws-sdk-go-v2/service/route53domains"
"github.com/aws/aws-sdk-go-v2/service/s3"
Expand Down Expand Up @@ -778,3 +779,11 @@ type KinesisClient interface {
ListStreams(ctx context.Context, params *kinesis.ListStreamsInput, optFns ...func(*kinesis.Options)) (*kinesis.ListStreamsOutput, error)
ListTagsForStream(ctx context.Context, params *kinesis.ListTagsForStreamInput, optFns ...func(*kinesis.Options)) (*kinesis.ListTagsForStreamOutput, error)
}

//go:generate mockgen -package=mocks -destination=./mocks/mock_resourcegroups.go . ResourceGroupsClient
type ResourceGroupsClient interface {
GetGroup(ctx context.Context, params *resourcegroups.GetGroupInput, optFns ...func(*resourcegroups.Options)) (*resourcegroups.GetGroupOutput, error)
GetGroupQuery(ctx context.Context, params *resourcegroups.GetGroupQueryInput, optFns ...func(*resourcegroups.Options)) (*resourcegroups.GetGroupQueryOutput, error)
GetTags(ctx context.Context, params *resourcegroups.GetTagsInput, optFns ...func(*resourcegroups.Options)) (*resourcegroups.GetTagsOutput, error)
ListGroups(ctx context.Context, params *resourcegroups.ListGroupsInput, optFns ...func(*resourcegroups.Options)) (*resourcegroups.ListGroupsOutput, error)
}
13 changes: 13 additions & 0 deletions docs/tables/aws_resourcegroups_resource_groups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# Table: aws_resourcegroups_resource_groups
The unique identifiers for a resource group
## Columns
| Name | Type | Description |
| ------------- | ------------- | ----- |
|account_id|text|The AWS Account ID of the resource.|
|region|text|The AWS Region of the resource.|
|tags|jsonb||
|resource_query_type|text|The type of the query.|
|resource_query|text|The query that defines a group or a search.|
|arn|text|The ARN of the resource group|
|name|text|The name of the resource group|
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/cloudquery/cq-provider-aws
go 1.18

require (
github.com/aws/aws-sdk-go-v2 v1.16.7
github.com/aws/aws-sdk-go-v2 v1.16.8
github.com/aws/aws-sdk-go-v2/config v1.15.14
github.com/aws/aws-sdk-go-v2/credentials v1.12.9
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.20
Expand Down Expand Up @@ -50,6 +50,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/qldb v1.14.8
github.com/aws/aws-sdk-go-v2/service/rds v1.21.5
github.com/aws/aws-sdk-go-v2/service/redshift v1.25.1
github.com/aws/aws-sdk-go-v2/service/resourcegroups v1.12.9
github.com/aws/aws-sdk-go-v2/service/route53 v1.21.2
github.com/aws/aws-sdk-go-v2/service/route53domains v1.12.7
github.com/aws/aws-sdk-go-v2/service/s3 v1.27.1
Expand Down Expand Up @@ -103,8 +104,8 @@ require (
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.3 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.8 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.9 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.15 // indirect
github.com/aws/aws-sdk-go-v2/service/athena v1.16.0
github.com/aws/aws-sdk-go-v2/service/backup v1.16.3
Expand Down
11 changes: 8 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/aws/aws-sdk-go-v2 v1.16.6/go.mod h1:6CpKuLXg2w7If3ABZCl/qZ6rEgwtjZTn4eAf4RcEyuw=
github.com/aws/aws-sdk-go-v2 v1.16.7 h1:zfBwXus3u14OszRxGcqCDS4MfMCv10e8SMJ2r8Xm0Ns=
github.com/aws/aws-sdk-go-v2 v1.16.7/go.mod h1:6CpKuLXg2w7If3ABZCl/qZ6rEgwtjZTn4eAf4RcEyuw=
github.com/aws/aws-sdk-go-v2 v1.16.8 h1:gOe9UPR98XSf7oEJCcojYg+N2/jCRm4DdeIsP85pIyQ=
github.com/aws/aws-sdk-go-v2 v1.16.8/go.mod h1:6CpKuLXg2w7If3ABZCl/qZ6rEgwtjZTn4eAf4RcEyuw=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.3 h1:S/ZBwevQkr7gv5YxONYpGQxlMFFYSRfz3RMcjsC9Qhk=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.3/go.mod h1:gNsR5CaXKmQSSzrmGxmwmct/r+ZBfbxorAuXYsj/M5Y=
github.com/aws/aws-sdk-go-v2/config v1.15.14 h1:+BqpqlydTq4c2et9Daury7gE+o67P4lbk7eybiCBNc4=
Expand All @@ -68,11 +69,13 @@ github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.8/go.mod h1:oL1Q3KuCq1D4NykQ
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.20 h1:J7/+NFr8N7ebaC/Khie8ptnWn0h436q1hblMeL53mww=
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.20/go.mod h1:IOgK2DAat3WO2qAaPmIzTdF+QqL18samL3dqZdjRBZI=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.13/go.mod h1:wLLesU+LdMZDM3U0PP9vZXJW39zmD/7L4nY2pSrYZ/g=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14 h1:2C0pYHcUBmdzPj+EKNC4qj97oK6yjrUhc1KoSodglvk=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14/go.mod h1:kdjrMwHwrC3+FsKhNcCMJ7tUVj/8uSD5CZXeQ4wV6fM=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.15 h1:bx5F2mr6H6FC7zNIQoDoUr8wEKnvmwRncujT3FYRtic=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.15/go.mod h1:pWrr2OoHlT7M/Pd2y4HV3gJyPb3qj5qMmnPkKSNPYK4=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.7/go.mod h1:93Uot80ddyVzSl//xEJreNKMhxntr71WtR3v/A1cRYk=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8 h1:2J+jdlBJWEmTyAwC82Ym68xCykIvnSnIN18b8xHGlcc=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8/go.mod h1:ZIV8GYoC6WLBW5KGs+o4rsc65/ozd+eQ0L31XF5VDwk=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.9 h1:5sbyznZC2TeFpa4fvtpvpcGbzeXEEs1l1Jo51ynUNsQ=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.9/go.mod h1:08tUpeSGN33QKSO7fwxXczNfiwCpbj+GxK6XKwqWVv0=
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.15 h1:QquxR7NH3ULBsKC+NoTpilzbKKS+5AELfNREInbhvas=
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.15/go.mod h1:Tkrthp/0sNBShQQsamR7j/zY4p19tVTAs+nnqhH6R3c=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.5 h1:tEEHn+PGAxRVqMPEhtU8oCSW/1Ge3zP5nUgPrGQNUPs=
Expand Down Expand Up @@ -181,6 +184,8 @@ github.com/aws/aws-sdk-go-v2/service/rds v1.21.5 h1:FxgP8Ty+UMcnFfLDYATBxBBwNqxd
github.com/aws/aws-sdk-go-v2/service/rds v1.21.5/go.mod h1:CETZ4xhuVW6rXcYVl9UIDaRPF1RDSjbr5IfTTCHswDM=
github.com/aws/aws-sdk-go-v2/service/redshift v1.25.1 h1:pt62Je9eCVqDdlfB25LF9bnsuW24jyHqlpwpdQ4AEio=
github.com/aws/aws-sdk-go-v2/service/redshift v1.25.1/go.mod h1:hb7YE8ERBjqEn3FV+xx4TVA1i/qX9aazglk+KBZK5lc=
github.com/aws/aws-sdk-go-v2/service/resourcegroups v1.12.9 h1:kz3eatV1DyQs28XMufhi7/Gk98F86pJm7liA430CiOA=
github.com/aws/aws-sdk-go-v2/service/resourcegroups v1.12.9/go.mod h1:kawkSDK0FqSCkzy89C6WQ+CsDixssVsPGe/Guh69N94=
github.com/aws/aws-sdk-go-v2/service/route53 v1.21.2 h1:t7yn/jSMOVFAlCpJqFzivixMRPI/MySAcD0LhXdjbf4=
github.com/aws/aws-sdk-go-v2/service/route53 v1.21.2/go.mod h1:ZBOkwr2JviKbUwZjhaUjQFaIbSx9XL0pQxNHaCqlMAU=
github.com/aws/aws-sdk-go-v2/service/route53domains v1.12.7 h1:myfNXFwvCde6JZAfy6YoI9VMKhefNDjhMQTVGQWJ3nY=
Expand Down
2 changes: 2 additions & 0 deletions resources/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"github.com/cloudquery/cq-provider-aws/resources/services/qldb"
"github.com/cloudquery/cq-provider-aws/resources/services/rds"
"github.com/cloudquery/cq-provider-aws/resources/services/redshift"
"github.com/cloudquery/cq-provider-aws/resources/services/resourcegroups"
"github.com/cloudquery/cq-provider-aws/resources/services/route53"
"github.com/cloudquery/cq-provider-aws/resources/services/s3"
"github.com/cloudquery/cq-provider-aws/resources/services/sagemaker"
Expand Down Expand Up @@ -233,6 +234,7 @@ func Provider() *provider.Provider {
"redshift.clusters": redshift.RedshiftClusters(),
"redshift.event_subscriptions": redshift.EventSubscriptions(),
"redshift.subnet_groups": redshift.RedshiftSubnetGroups(),
"resourcegroups.resource_groups": resourcegroups.ResourceGroups(),
"route53.domains": route53.Route53Domains(),
"route53.health_checks": route53.Route53HealthChecks(),
"route53.hosted_zones": route53.Route53HostedZones(),
Expand Down
53 changes: 53 additions & 0 deletions resources/services/resourcegroups/gen.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
service = "aws"
bbernays marked this conversation as resolved.
Show resolved Hide resolved
output_directory = "."
add_generate = true

description_modifier "remove_read_only" {
words = [" This member is required."]
}

resource "aws" "resourcegroups" "resource_groups" {
path = "../resourcegroups.ResourceGroupWrapper"

ignoreError "IgnoreCommonErrors" {
path = "github.com/cloudquery/cq-provider-aws/client.IgnoreCommonErrors"
}
multiplex "AwsAccountRegion" {
path = "github.com/cloudquery/cq-provider-aws/client.ServiceAccountRegionMultiplexer"
params = ["resource-groups"]
}
deleteFilter "AccountRegionFilter" {
path = "github.com/cloudquery/cq-provider-aws/client.DeleteAccountRegionFilter"
}

options {
primary_keys = ["arn"]
}

column "group_arn" {
rename = "arn"
}

column "group_name" {
rename = "group"
}

userDefinedColumn "account_id" {
type = "string"
description = "The AWS Account ID of the resource."
resolver "resolveAWSAccount" {
path = "github.com/cloudquery/cq-provider-aws/client.ResolveAWSAccount"
}
}
userDefinedColumn "region" {
type = "string"
description = "The AWS Region of the resource."
resolver "resolveAWSRegion" {
path = "github.com/cloudquery/cq-provider-aws/client.ResolveAWSRegion"
}
}
userDefinedColumn "tags" {
type = "json"
generate_resolver = true
}
}
Loading