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

Commit

Permalink
feat: Add support for resource groups (#1396)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-tylr committed Aug 10, 2022
1 parent 34fa4d6 commit dc6aeab
Show file tree
Hide file tree
Showing 16 changed files with 481 additions and 0 deletions.
3 changes: 3 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,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 @@ -168,6 +169,7 @@ type Services struct {
QLDB QLDBClient
RDS RdsClient
Redshift RedshiftClient
ResourceGroups ResourceGroupsClient
Route53 Route53Client
Route53Domains Route53DomainsClient
S3 S3Client
Expand Down Expand Up @@ -667,6 +669,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 @@ -51,6 +51,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 @@ -796,3 +797,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)
}
14 changes: 14 additions & 0 deletions docs/tables/aws_resourcegroups_resource_groups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# Table: aws_resourcegroups_resource_groups

## Columns
| Name | Type | Description |
| ------------- | ------------- | ----- |
|account_id|text|The AWS Account ID of the resource.|
|region|text|The AWS Region of the resource.|
|tags|jsonb||
|arn|text|The ARN of the resource group|
|group|text|The name of the resource group|
|group_description|text|The description of the resource group|
|resource_query|text|The query that defines a group or a search|
|resource_query_type|text|The type of the query|
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,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 @@ -51,6 +51,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 @@ -238,6 +239,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
54 changes: 54 additions & 0 deletions resources/services/resourcegroups/gen.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//check-for-changes
service = "aws"
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

0 comments on commit dc6aeab

Please sign in to comment.