Skip to content

Commit 361df3f

Browse files
authored
feat(aws): Add Support for Config Delivery Channels (#10150)
#### Summary
1 parent a39c3ef commit 361df3f

File tree

8 files changed

+186
-0
lines changed

8 files changed

+186
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@
126126
- [aws_config_configuration_recorders](../../../../../website/tables/aws/aws_config_configuration_recorders.md)
127127
- [aws_config_conformance_packs](../../../../../website/tables/aws/aws_config_conformance_packs.md)
128128
- [aws_config_conformance_pack_rule_compliances](../../../../../website/tables/aws/aws_config_conformance_pack_rule_compliances.md)
129+
- [aws_config_delivery_channels](../../../../../website/tables/aws/aws_config_delivery_channels.md)
130+
- [aws_config_delivery_channel_statuses](../../../../../website/tables/aws/aws_config_delivery_channel_statuses.md)
129131
- [aws_dax_clusters](../../../../../website/tables/aws/aws_dax_clusters.md)
130132
- [aws_db_proxies](../../../../../website/tables/aws/aws_db_proxies.md)
131133
- [aws_directconnect_connections](../../../../../website/tables/aws/aws_directconnect_connections.md)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ func tables() []*schema.Table {
177177
config.ConfigRules(),
178178
config.ConfigurationRecorders(),
179179
config.ConformancePacks(),
180+
config.DeliveryChannels(),
180181
dax.Clusters(),
181182
directconnect.Connections(),
182183
directconnect.Gateways(),
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package config
2+
3+
import (
4+
"context"
5+
6+
"github.com/aws/aws-sdk-go-v2/aws"
7+
"github.com/aws/aws-sdk-go-v2/service/configservice"
8+
"github.com/aws/aws-sdk-go-v2/service/configservice/types"
9+
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
10+
"github.com/cloudquery/plugin-sdk/v2/schema"
11+
"github.com/cloudquery/plugin-sdk/v2/transformers"
12+
)
13+
14+
func deliveryChannelStatuses() *schema.Table {
15+
tableName := "aws_config_delivery_channel_statuses"
16+
return &schema.Table{
17+
Name: tableName,
18+
Description: `https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeDeliveryChannelStatus.html`,
19+
Resolver: fetchDeliveryChannelStatuses,
20+
Multiplex: client.ServiceAccountRegionMultiplexer(tableName, "config"),
21+
Transform: transformers.TransformWithStruct(&types.DeliveryChannelStatus{}, transformers.WithPrimaryKeys("Name")),
22+
Columns: []schema.Column{
23+
client.DefaultAccountIDColumn(true),
24+
client.DefaultRegionColumn(true),
25+
},
26+
}
27+
}
28+
29+
func fetchDeliveryChannelStatuses(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
30+
ruleDetail := parent.Item.(types.DeliveryChannel)
31+
c := meta.(*client.Client)
32+
svc := c.Services().Configservice
33+
34+
input := &configservice.DescribeDeliveryChannelStatusInput{
35+
DeliveryChannelNames: []string{aws.ToString(ruleDetail.Name)},
36+
}
37+
38+
response, err := svc.DescribeDeliveryChannelStatus(ctx, input)
39+
if err != nil {
40+
return err
41+
}
42+
res <- response.DeliveryChannelsStatus
43+
return nil
44+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package config
2+
3+
import (
4+
"context"
5+
6+
"github.com/aws/aws-sdk-go-v2/service/configservice"
7+
"github.com/aws/aws-sdk-go-v2/service/configservice/types"
8+
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
9+
"github.com/cloudquery/plugin-sdk/v2/schema"
10+
"github.com/cloudquery/plugin-sdk/v2/transformers"
11+
)
12+
13+
func DeliveryChannels() *schema.Table {
14+
tableName := "aws_config_delivery_channels"
15+
return &schema.Table{
16+
Name: tableName,
17+
Description: `https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeDeliveryChannels.html`,
18+
Resolver: fetchDeliveryChannels,
19+
Multiplex: client.ServiceAccountRegionMultiplexer(tableName, "config"),
20+
Transform: transformers.TransformWithStruct(&types.DeliveryChannel{}, transformers.WithPrimaryKeys("Name")),
21+
Columns: []schema.Column{
22+
client.DefaultAccountIDColumn(true),
23+
client.DefaultRegionColumn(true),
24+
},
25+
26+
Relations: []*schema.Table{
27+
deliveryChannelStatuses(),
28+
},
29+
}
30+
}
31+
32+
func fetchDeliveryChannels(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
33+
svc := meta.(*client.Client).Services().Configservice
34+
response, err := svc.DescribeDeliveryChannels(ctx, &configservice.DescribeDeliveryChannelsInput{})
35+
if err != nil {
36+
return err
37+
}
38+
res <- response.DeliveryChannels
39+
return nil
40+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package config
2+
3+
import (
4+
"testing"
5+
6+
"github.com/aws/aws-sdk-go-v2/service/configservice"
7+
"github.com/aws/aws-sdk-go-v2/service/configservice/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/v2/faker"
11+
"github.com/golang/mock/gomock"
12+
)
13+
14+
func buildConfigDeliveryChannels(t *testing.T, ctrl *gomock.Controller) client.Services {
15+
m := mocks.NewMockConfigserviceClient(ctrl)
16+
17+
var dc types.DeliveryChannel
18+
if err := faker.FakeObject(&dc); err != nil {
19+
t.Fatal(err)
20+
}
21+
var dcs types.DeliveryChannelStatus
22+
if err := faker.FakeObject(&dcs); err != nil {
23+
t.Fatal(err)
24+
}
25+
26+
m.EXPECT().DescribeDeliveryChannels(gomock.Any(), gomock.Any(), gomock.Any()).Return(
27+
&configservice.DescribeDeliveryChannelsOutput{
28+
DeliveryChannels: []types.DeliveryChannel{dc},
29+
}, nil)
30+
m.EXPECT().DescribeDeliveryChannelStatus(gomock.Any(), gomock.Any(), gomock.Any()).Return(
31+
&configservice.DescribeDeliveryChannelStatusOutput{
32+
DeliveryChannelsStatus: []types.DeliveryChannelStatus{dcs},
33+
}, nil)
34+
35+
return client.Services{
36+
Configservice: m,
37+
}
38+
}
39+
40+
func TestConfigDeliveryChannels(t *testing.T) {
41+
client.AwsMockTestHelper(t, DeliveryChannels(), buildConfigDeliveryChannels, client.TestOptions{})
42+
}

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

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Table: aws_config_delivery_channel_statuses
2+
3+
This table shows data for Config Delivery Channel Statuses.
4+
5+
https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeDeliveryChannelStatus.html
6+
7+
The composite primary key for this table is (**account_id**, **region**, **name**).
8+
9+
## Relations
10+
11+
This table depends on [aws_config_delivery_channels](aws_config_delivery_channels).
12+
13+
## Columns
14+
15+
| Name | Type |
16+
| ------------- | ------------- |
17+
|_cq_source_name|String|
18+
|_cq_sync_time|Timestamp|
19+
|_cq_id|UUID|
20+
|_cq_parent_id|UUID|
21+
|account_id (PK)|String|
22+
|region (PK)|String|
23+
|config_history_delivery_info|JSON|
24+
|config_snapshot_delivery_info|JSON|
25+
|config_stream_delivery_info|JSON|
26+
|name (PK)|String|
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Table: aws_config_delivery_channels
2+
3+
This table shows data for Config Delivery Channels.
4+
5+
https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeDeliveryChannels.html
6+
7+
The composite primary key for this table is (**account_id**, **region**, **name**).
8+
9+
## Relations
10+
11+
The following tables depend on aws_config_delivery_channels:
12+
- [aws_config_delivery_channel_statuses](aws_config_delivery_channel_statuses)
13+
14+
## Columns
15+
16+
| Name | Type |
17+
| ------------- | ------------- |
18+
|_cq_source_name|String|
19+
|_cq_sync_time|Timestamp|
20+
|_cq_id|UUID|
21+
|_cq_parent_id|UUID|
22+
|account_id (PK)|String|
23+
|region (PK)|String|
24+
|config_snapshot_delivery_properties|JSON|
25+
|name (PK)|String|
26+
|s3_bucket_name|String|
27+
|s3_key_prefix|String|
28+
|s3_kms_key_arn|String|
29+
|sns_topic_arn|String|

0 commit comments

Comments
 (0)