Skip to content

Commit 8233160

Browse files
authored
feat(aws): Add RDS DB Proxies (#6831)
#### Summary <!-- Explain what problem this PR addresses --> Add's support for RDS DB Proxies <!--
1 parent 0c8c0d3 commit 8233160

7 files changed

Lines changed: 161 additions & 0 deletions

File tree

plugins/source/aws/docs/tables/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
- [aws_config_conformance_packs](aws_config_conformance_packs.md)
104104
- [aws_config_conformance_pack_rule_compliances](aws_config_conformance_pack_rule_compliances.md)
105105
- [aws_dax_clusters](aws_dax_clusters.md)
106+
- [aws_db_proxies](aws_db_proxies.md)
106107
- [aws_directconnect_connections](aws_directconnect_connections.md)
107108
- [aws_directconnect_gateways](aws_directconnect_gateways.md)
108109
- [aws_directconnect_gateway_associations](aws_directconnect_gateway_associations.md)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Table: aws_db_proxies
2+
3+
https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DBProxy.html
4+
5+
The primary key for this table is **arn**.
6+
7+
## Columns
8+
9+
| Name | Type |
10+
| ------------- | ------------- |
11+
|_cq_source_name|String|
12+
|_cq_sync_time|Timestamp|
13+
|_cq_id|UUID|
14+
|_cq_parent_id|UUID|
15+
|account_id|String|
16+
|region|String|
17+
|arn (PK)|String|
18+
|tags|JSON|
19+
|auth|JSON|
20+
|created_date|Timestamp|
21+
|db_proxy_arn|String|
22+
|db_proxy_name|String|
23+
|debug_logging|Bool|
24+
|endpoint|String|
25+
|engine_family|String|
26+
|idle_client_timeout|Int|
27+
|require_tls|Bool|
28+
|role_arn|String|
29+
|status|String|
30+
|updated_date|Timestamp|
31+
|vpc_id|String|
32+
|vpc_security_group_ids|StringArray|
33+
|vpc_subnet_ids|StringArray|

plugins/source/aws/resources/plugin/tables.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ func tables() []*schema.Table {
357357
rds.ClusterSnapshots(),
358358
rds.Clusters(),
359359
rds.DbParameterGroups(),
360+
rds.DbProxies(),
360361
rds.DbSecurityGroups(),
361362
rds.DbSnapshots(),
362363
rds.EventSubscriptions(),
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package rds
2+
3+
import (
4+
"github.com/aws/aws-sdk-go-v2/service/rds/types"
5+
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
6+
"github.com/cloudquery/plugin-sdk/schema"
7+
"github.com/cloudquery/plugin-sdk/transformers"
8+
)
9+
10+
func DbProxies() *schema.Table {
11+
return &schema.Table{
12+
Name: "aws_db_proxies",
13+
Description: `https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DBProxy.html`,
14+
Resolver: fetchDbProxies,
15+
Transform: transformers.TransformWithStruct(&types.DBProxy{}),
16+
Multiplex: client.ServiceAccountRegionMultiplexer("rds"),
17+
Columns: []schema.Column{
18+
{
19+
Name: "account_id",
20+
Type: schema.TypeString,
21+
Resolver: client.ResolveAWSAccount,
22+
},
23+
{
24+
Name: "region",
25+
Type: schema.TypeString,
26+
Resolver: client.ResolveAWSRegion,
27+
},
28+
{
29+
Name: "arn",
30+
Type: schema.TypeString,
31+
Resolver: schema.PathResolver("DBProxyArn"),
32+
CreationOptions: schema.ColumnCreationOptions{
33+
PrimaryKey: true,
34+
},
35+
},
36+
{
37+
Name: "tags",
38+
Type: schema.TypeJSON,
39+
Resolver: resolveRdsDbProxyTags,
40+
},
41+
},
42+
}
43+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package rds
2+
3+
import (
4+
"context"
5+
6+
"github.com/aws/aws-sdk-go-v2/aws"
7+
"github.com/aws/aws-sdk-go-v2/service/rds"
8+
"github.com/aws/aws-sdk-go-v2/service/rds/types"
9+
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
10+
"github.com/cloudquery/plugin-sdk/schema"
11+
)
12+
13+
func fetchDbProxies(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
14+
c := meta.(*client.Client)
15+
svc := c.Services().Rds
16+
input := rds.DescribeDBProxiesInput{}
17+
for {
18+
output, err := svc.DescribeDBProxies(ctx, &input)
19+
if err != nil {
20+
return err
21+
}
22+
res <- output.DBProxies
23+
if aws.ToString(output.Marker) == "" {
24+
break
25+
}
26+
input.Marker = output.Marker
27+
}
28+
return nil
29+
}
30+
31+
func resolveRdsDbProxyTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
32+
g := resource.Item.(types.DBProxy)
33+
cl := meta.(*client.Client)
34+
svc := cl.Services().Rds
35+
out, err := svc.ListTagsForResource(ctx, &rds.ListTagsForResourceInput{ResourceName: g.DBProxyArn})
36+
if err != nil {
37+
return err
38+
}
39+
return resource.Set(c.Name, client.TagsToMap(out.TagList))
40+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package rds
2+
3+
import (
4+
"testing"
5+
6+
"github.com/aws/aws-sdk-go-v2/service/rds"
7+
"github.com/aws/aws-sdk-go-v2/service/rds/types"
8+
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
9+
"github.com/cloudquery/cloudquery/plugins/source/aws/client/mocks"
10+
"github.com/cloudquery/plugin-sdk/faker"
11+
"github.com/golang/mock/gomock"
12+
)
13+
14+
func buildRdsDbProxiesMock(t *testing.T, ctrl *gomock.Controller) client.Services {
15+
m := mocks.NewMockRdsClient(ctrl)
16+
proxy := types.DBProxy{}
17+
err := faker.FakeObject(&proxy)
18+
if err != nil {
19+
t.Fatal(err)
20+
}
21+
22+
tags := rds.ListTagsForResourceOutput{}
23+
err = faker.FakeObject(&tags)
24+
if err != nil {
25+
t.Fatal(err)
26+
}
27+
28+
m.EXPECT().DescribeDBProxies(gomock.Any(), gomock.Any(), gomock.Any()).Return(
29+
&rds.DescribeDBProxiesOutput{
30+
DBProxies: []types.DBProxy{proxy},
31+
}, nil)
32+
m.EXPECT().ListTagsForResource(gomock.Any(), gomock.Any(), gomock.Any()).Return(
33+
&tags, nil)
34+
35+
return client.Services{
36+
Rds: m,
37+
}
38+
}
39+
40+
func TestRdsDbProxues(t *testing.T) {
41+
client.AwsMockTestHelper(t, DbProxies(), buildRdsDbProxiesMock, client.TestOptions{})
42+
}

website/pages/docs/plugins/sources/aws/tables.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
- [aws_config_conformance_packs](https://github.com/cloudquery/cloudquery/blob/main/plugins/source/aws/docs/tables/aws_config_conformance_packs.md)
104104
- [aws_config_conformance_pack_rule_compliances](https://github.com/cloudquery/cloudquery/blob/main/plugins/source/aws/docs/tables/aws_config_conformance_pack_rule_compliances.md)
105105
- [aws_dax_clusters](https://github.com/cloudquery/cloudquery/blob/main/plugins/source/aws/docs/tables/aws_dax_clusters.md)
106+
- [aws_db_proxies](https://github.com/cloudquery/cloudquery/blob/main/plugins/source/aws/docs/tables/aws_db_proxies.md)
106107
- [aws_directconnect_connections](https://github.com/cloudquery/cloudquery/blob/main/plugins/source/aws/docs/tables/aws_directconnect_connections.md)
107108
- [aws_directconnect_gateways](https://github.com/cloudquery/cloudquery/blob/main/plugins/source/aws/docs/tables/aws_directconnect_gateways.md)
108109
- [aws_directconnect_gateway_associations](https://github.com/cloudquery/cloudquery/blob/main/plugins/source/aws/docs/tables/aws_directconnect_gateway_associations.md)

0 commit comments

Comments
 (0)