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

Add more RDS resources #333

Merged
merged 6 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this provider will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### 🚀 Added
* Added `aws_rds_db_parameter_groups`, `aws_rds_cluster_parameter_groups` and `aws_rds_db_security_groups` resources [#333](https://github.com/cloudquery/cq-provider-aws/pull/333)

## [v0.8.1] - 2021-12-08
###### SDK Version: 0.5.3

Expand Down
100 changes: 100 additions & 0 deletions client/mocks/mock_rds.go

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

5 changes: 5 additions & 0 deletions client/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,15 @@ type OrganizationsClient interface {
//go:generate mockgen -package=mocks -destination=./mocks/mock_rds.go . RdsClient
type RdsClient interface {
DescribeCertificates(ctx context.Context, params *rds.DescribeCertificatesInput, optFns ...func(*rds.Options)) (*rds.DescribeCertificatesOutput, error)
DescribeDBClusterParameterGroups(ctx context.Context, params *rds.DescribeDBClusterParameterGroupsInput, optFns ...func(*rds.Options)) (*rds.DescribeDBClusterParameterGroupsOutput, error)
DescribeDBClusterParameters(ctx context.Context, params *rds.DescribeDBClusterParametersInput, optFns ...func(*rds.Options)) (*rds.DescribeDBClusterParametersOutput, error)
DescribeDBClusters(ctx context.Context, params *rds.DescribeDBClustersInput, optFns ...func(*rds.Options)) (*rds.DescribeDBClustersOutput, error)
DescribeDBClusterSnapshotAttributes(ctx context.Context, params *rds.DescribeDBClusterSnapshotAttributesInput, optFns ...func(*rds.Options)) (*rds.DescribeDBClusterSnapshotAttributesOutput, error)
DescribeDBClusterSnapshots(ctx context.Context, params *rds.DescribeDBClusterSnapshotsInput, optFns ...func(*rds.Options)) (*rds.DescribeDBClusterSnapshotsOutput, error)
DescribeDBInstances(ctx context.Context, params *rds.DescribeDBInstancesInput, optFns ...func(*rds.Options)) (*rds.DescribeDBInstancesOutput, error)
DescribeDBParameterGroups(ctx context.Context, params *rds.DescribeDBParameterGroupsInput, optFns ...func(*rds.Options)) (*rds.DescribeDBParameterGroupsOutput, error)
DescribeDBParameters(ctx context.Context, params *rds.DescribeDBParametersInput, optFns ...func(*rds.Options)) (*rds.DescribeDBParametersOutput, error)
DescribeDBSecurityGroups(ctx context.Context, params *rds.DescribeDBSecurityGroupsInput, optFns ...func(*rds.Options)) (*rds.DescribeDBSecurityGroupsOutput, error)
DescribeDBSnapshotAttributes(ctx context.Context, params *rds.DescribeDBSnapshotAttributesInput, optFns ...func(*rds.Options)) (*rds.DescribeDBSnapshotAttributesOutput, error)
DescribeDBSnapshots(ctx context.Context, params *rds.DescribeDBSnapshotsInput, optFns ...func(*rds.Options)) (*rds.DescribeDBSnapshotsOutput, error)
DescribeDBSubnetGroups(ctx context.Context, params *rds.DescribeDBSubnetGroupsInput, optFns ...func(*rds.Options)) (*rds.DescribeDBSubnetGroupsOutput, error)
Expand Down
13 changes: 13 additions & 0 deletions docs/tables/aws_rds_cluster_parameter_groups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# Table: aws_rds_cluster_parameter_groups
Contains the details of an Amazon RDS DB cluster parameter group
## Columns
| Name | Type | Description |
| ------------- | ------------- | ----- |
|account_id|text|The AWS Account ID of the resource.|
|region|text|The AWS Region of the resource.|
|arn|text|The Amazon Resource Name (ARN) for the DB cluster parameter group.|
|name|text|The name of the DB cluster parameter group.|
|family|text|The name of the DB parameter group family that this DB cluster parameter group is compatible with.|
|description|text|Provides the customer-specified description for this DB cluster parameter group.|
|tags|jsonb|List of tags|
18 changes: 18 additions & 0 deletions docs/tables/aws_rds_cluster_parameters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

# Table: aws_rds_cluster_parameters
This data type is used as a request parameter in the ModifyDBParameterGroup and ResetDBParameterGroup actions
## Columns
| Name | Type | Description |
| ------------- | ------------- | ----- |
|cluster_parameter_group_cq_id|uuid|Unique CloudQuery ID of aws_rds_cluster_parameter_groups table (FK)|
|allowed_values|text|Specifies the valid range of values for the parameter.|
|apply_method|text|Indicates when to apply parameter updates.|
|apply_type|text|Specifies the engine specific parameters type.|
|data_type|text|Specifies the valid data type for the parameter.|
|description|text|Provides a description of the parameter.|
|is_modifiable|boolean|Indicates whether (true) or not (false) the parameter can be modified|
|minimum_engine_version|text|The earliest engine version to which the parameter can apply.|
|parameter_name|text|Specifies the name of the parameter.|
|parameter_value|text|Specifies the value of the parameter.|
|source|text|Indicates the source of the parameter value.|
|supported_engine_modes|text[]|The valid DB engine modes.|
13 changes: 13 additions & 0 deletions docs/tables/aws_rds_db_parameter_groups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# Table: aws_rds_db_parameter_groups
Contains the details of an Amazon RDS DB parameter group
## Columns
| Name | Type | Description |
| ------------- | ------------- | ----- |
|account_id|text|The AWS Account ID of the resource.|
|region|text|The AWS Region of the resource.|
|arn|text|The Amazon Resource Name (ARN) for the DB parameter group.|
|family|text|The name of the DB parameter group family that this DB parameter group is compatible with.|
|name|text|The name of the DB parameter group.|
|description|text|Provides the customer-specified description for this DB parameter group.|
|tags|jsonb|List of tags|
18 changes: 18 additions & 0 deletions docs/tables/aws_rds_db_parameters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

# Table: aws_rds_db_parameters
Database Parameters
## Columns
| Name | Type | Description |
| ------------- | ------------- | ----- |
|db_parameter_group_cq_id|uuid|Unique CloudQuery ID of aws_rds_db_parameter_groups table (FK)|
|allowed_values|text|Specifies the valid range of values for the parameter.|
|apply_method|text|Indicates when to apply parameter updates.|
|apply_type|text|Specifies the engine specific parameters type.|
|data_type|text|Specifies the valid data type for the parameter.|
|description|text|Provides a description of the parameter.|
|is_modifiable|boolean|Indicates whether (true) or not (false) the parameter can be modified|
|minimum_engine_version|text|The earliest engine version to which the parameter can apply.|
|parameter_name|text|Specifies the name of the parameter.|
|parameter_value|text|Specifies the value of the parameter.|
|source|text|Indicates the source of the parameter value.|
|supported_engine_modes|text[]|The valid DB engine modes.|
16 changes: 16 additions & 0 deletions docs/tables/aws_rds_db_security_groups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

# Table: aws_rds_db_security_groups
Contains the details for an Amazon RDS DB security group
## Columns
| Name | Type | Description |
| ------------- | ------------- | ----- |
|account_id|text|The AWS Account ID of the resource.|
|region|text|The AWS Region of the resource.|
|arn|text|The Amazon Resource Name (ARN) for the DB security group.|
|description|text|Provides the description of the DB security group.|
|name|text|Specifies the name of the DB security group.|
|ec2_security_groups|jsonb|Contains a list of EC2 Security Group elements.|
|ip_ranges|jsonb|Contains a list of IP range elements.|
|owner_id|text|Provides the AWS ID of the owner of a specific DB security group.|
|vpc_id|text|Provides the VpcId of the DB security group.|
|tags|jsonb|List of tags|
7 changes: 7 additions & 0 deletions resources/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package resources

import "fmt"

func unexpectedResourceType(want, got interface{}) error {
return fmt.Errorf("expected resource of type %T, but got %T", want, got)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package integration_tests

import (
"fmt"
"testing"

"github.com/cloudquery/cq-provider-aws/resources"
providertest "github.com/cloudquery/cq-provider-sdk/provider/testing"
)

func TestIntegrationRdsClusterParameterGroups(t *testing.T) {
table := resources.RdsClusterParameterGroups()
awsTestIntegrationHelper(t, table, nil, func(res *providertest.ResourceIntegrationTestData) providertest.ResourceIntegrationVerification {
return providertest.ResourceIntegrationVerification{
Name: table.Name,
ExpectedValues: []providertest.ExpectedValue{
{
Count: 1,
Data: map[string]interface{}{
"name": fmt.Sprintf("rds-cluster-pg-%s-%s", res.Prefix, res.Suffix),
"family": "aurora-mysql8.0",
"description": "Test RDS cluster parameter group",
"tags": map[string]interface{}{
"Type": "integration_test",
"TestId": res.Suffix,
},
},
},
},
Relations: []*providertest.ResourceIntegrationVerification{{
Name: "aws_rds_cluster_parameters",
ForeignKeyName: "cluster_parameter_group_cq_id",
ExpectedValues: []providertest.ExpectedValue{
{
Count: 1,
Data: map[string]interface{}{
"parameter_name": "character_set_client",
"parameter_value": "utf8",
},
},
{
Count: 1,
Data: map[string]interface{}{
"parameter_name": "character_set_server",
"parameter_value": "utf8",
},
},
},
}},
}
})
}
52 changes: 52 additions & 0 deletions resources/integration_tests/aws_rds_db_parameter_groups_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package integration_tests

import (
"fmt"
"testing"

"github.com/cloudquery/cq-provider-aws/resources"
providertest "github.com/cloudquery/cq-provider-sdk/provider/testing"
)

func TestIntegrationRdsDbParameterGroups(t *testing.T) {
table := resources.RdsDbParameterGroups()
awsTestIntegrationHelper(t, table, nil, func(res *providertest.ResourceIntegrationTestData) providertest.ResourceIntegrationVerification {
return providertest.ResourceIntegrationVerification{
Name: table.Name,
ExpectedValues: []providertest.ExpectedValue{
{
Count: 1,
Data: map[string]interface{}{
"name": fmt.Sprintf("rds-db-pg-%s-%s", res.Prefix, res.Suffix),
"family": "mysql8.0",
"description": "Test RDS DB parameter group",
"tags": map[string]interface{}{
"Type": "integration_test",
"TestId": res.Suffix,
},
},
},
},
Relations: []*providertest.ResourceIntegrationVerification{{
Name: "aws_rds_db_parameters",
ForeignKeyName: "db_parameter_group_cq_id",
ExpectedValues: []providertest.ExpectedValue{
{
Count: 1,
Data: map[string]interface{}{
"parameter_name": "character_set_client",
"parameter_value": "utf8",
},
},
{
Count: 1,
Data: map[string]interface{}{
"parameter_name": "character_set_server",
"parameter_value": "utf8",
},
},
},
}},
}
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "aws_rds_cluster_parameter_group" "rds_cluster_param_group" {
name = "rds-cluster-pg-${var.test_prefix}-${var.test_suffix}"
family = "aurora-mysql8.0"
description = "Test RDS cluster parameter group"

parameter {
name = "character_set_server"
value = "utf8"
}

parameter {
name = "character_set_client"
value = "utf8"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "aws_db_parameter_group" "db_parameter_group" {
name = "rds-db-pg-${var.test_prefix}-${var.test_suffix}"
family = "mysql8.0"
description = "Test RDS DB parameter group"

parameter {
name = "character_set_server"
value = "utf8"
}

parameter {
name = "character_set_client"
value = "utf8"
}
}
3 changes: 3 additions & 0 deletions resources/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ func Provider() *provider.Provider {
"lambda.layers": LambdaLayers(),
"mq.brokers": MqBrokers(),
"organizations.accounts": OrganizationsAccounts(),
"rds.cluster_parameter_groups": RdsClusterParameterGroups(),
"rds.db_parameter_groups": RdsDbParameterGroups(),
"rds.db_security_groups": RdsDbSecurityGroups(),
"rds.event_subscriptions": RdsEventSubscriptions(),
"rds.certificates": RdsCertificates(),
"rds.clusters": RdsClusters(),
Expand Down
Loading