Skip to content
1 change: 1 addition & 0 deletions plugins/source/aws/docs/tables/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
- [aws_computeoptimizer_enrollment_statuses](../../../../../website/tables/aws/aws_computeoptimizer_enrollment_statuses.md)
- [aws_computeoptimizer_lambda_function_recommendations](../../../../../website/tables/aws/aws_computeoptimizer_lambda_function_recommendations.md)
- [aws_config_config_rules](../../../../../website/tables/aws/aws_config_config_rules.md)
- [aws_config_config_rule_compliance_details](../../../../../website/tables/aws/aws_config_config_rule_compliance_details.md)
- [aws_config_config_rule_compliances](../../../../../website/tables/aws/aws_config_config_rule_compliances.md)
- [aws_config_remediation_configurations](../../../../../website/tables/aws/aws_config_remediation_configurations.md)
- [aws_config_configuration_aggregators](../../../../../website/tables/aws/aws_config_configuration_aggregators.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package config

import (
"context"

"github.com/aws/aws-sdk-go-v2/service/configservice"
"github.com/aws/aws-sdk-go-v2/service/configservice/types"
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
"github.com/cloudquery/plugin-sdk/v2/schema"
"github.com/cloudquery/plugin-sdk/v2/transformers"
)

func configRuleComplianceDetails() *schema.Table {
tableName := "aws_config_config_rule_compliance_details"
return &schema.Table{
Name: tableName,
Description: `https://docs.aws.amazon.com/config/latest/APIReference/API_EvaluationResult.html`,
Resolver: fetchConfigConfigRuleComplianceDetails,
Multiplex: client.ServiceAccountRegionMultiplexer(tableName, "config"),
// no primary key because all the relevant candidate fields can either be null or are not
// uniquely identifying of a resource. For example, ResourceEvaluationId can be null,
// and so can ResultToken. However, hashing the entire object can work because a combination of
// all fields must be unique.
Transform: transformers.TransformWithStruct(&types.EvaluationResult{}),
Columns: []schema.Column{
client.DefaultAccountIDColumn(true),
client.DefaultRegionColumn(true),
{
Name: "config_rule_name",
Type: schema.TypeString,
Resolver: schema.ParentColumnResolver("config_rule_name"),
},
},
}
}

func fetchConfigConfigRuleComplianceDetails(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
ruleDetail := parent.Item.(types.ConfigRule)
c := meta.(*client.Client)
svc := c.Services().Configservice

input := &configservice.GetComplianceDetailsByConfigRuleInput{
ConfigRuleName: ruleDetail.ConfigRuleName,
Limit: 100,
}
p := configservice.NewGetComplianceDetailsByConfigRulePaginator(svc, input)
for p.HasMorePages() {
response, err := p.NextPage(ctx, func(options *configservice.Options) {
options.Region = c.Region
})
if err != nil {
return err
}
res <- response.EvaluationResults
}
return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package config

import (
"testing"

"github.com/aws/aws-sdk-go-v2/service/configservice"
"github.com/aws/aws-sdk-go-v2/service/configservice/types"
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
"github.com/cloudquery/cloudquery/plugins/source/aws/client/mocks"
"github.com/cloudquery/plugin-sdk/v2/faker"
"github.com/golang/mock/gomock"
)

func buildComplianceDetails(t *testing.T, m *mocks.MockConfigserviceClient) client.Services {
l := types.EvaluationResult{}
if err := faker.FakeObject(&l); err != nil {
t.Fatal(err)
}
m.EXPECT().GetComplianceDetailsByConfigRule(gomock.Any(), gomock.Any(), gomock.Any()).Return(
&configservice.GetComplianceDetailsByConfigRuleOutput{
EvaluationResults: []types.EvaluationResult{l},
}, nil)
return client.Services{
Configservice: m,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func ConfigRules() *schema.Table {
tableName := "aws_config_config_rules"
return &schema.Table{
Name: tableName,
Description: `https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeConfigRules.html`,
Description: `https://docs.aws.amazon.com/config/latest/APIReference/API_ConfigRule.html`,
Resolver: fetchConfigConfigRules,
Multiplex: client.ServiceAccountRegionMultiplexer(tableName, "config"),
Transform: transformers.TransformWithStruct(&types.ConfigRule{}),
Expand All @@ -33,6 +33,7 @@ func ConfigRules() *schema.Table {

Relations: []*schema.Table{
configRuleCompliances(),
configRuleComplianceDetails(),
remediationConfigurations(),
},
}
Expand All @@ -42,8 +43,7 @@ func fetchConfigConfigRules(ctx context.Context, meta schema.ClientMeta, parent
c := meta.(*client.Client)
svc := c.Services().Configservice

input := &configservice.DescribeConfigRulesInput{}
p := configservice.NewDescribeConfigRulesPaginator(svc, input)
p := configservice.NewDescribeConfigRulesPaginator(svc, nil)
for p.HasMorePages() {
response, err := p.NextPage(ctx, func(options *configservice.Options) {
options.Region = c.Region
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func buildConfigRules(t *testing.T, ctrl *gomock.Controller) client.Services {
ComplianceByConfigRules: []types.ComplianceByConfigRule{sl},
}, nil)
buildRemediationConfigurations(t, m)
buildComplianceDetails(t, m)
return client.Services{
Configservice: m,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func ConfigurationAggregators() *schema.Table {
tableName := "aws_config_configuration_aggregators"
return &schema.Table{
Name: tableName,
Description: `https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeConfigurationAggregators.html`,
Description: `https://docs.aws.amazon.com/config/latest/APIReference/API_ConfigurationAggregator.html`,
Resolver: fetchConfigurationAggregators,
Multiplex: client.ServiceAccountRegionMultiplexer(tableName, "config"),
Transform: transformers.TransformWithStruct(&types.ConfigurationAggregator{}),
Expand All @@ -38,8 +38,7 @@ func fetchConfigurationAggregators(ctx context.Context, meta schema.ClientMeta,
c := meta.(*client.Client)
svc := c.Services().Configservice

input := &configservice.DescribeConfigurationAggregatorsInput{}
p := configservice.NewDescribeConfigurationAggregatorsPaginator(svc, input)
p := configservice.NewDescribeConfigurationAggregatorsPaginator(svc, nil)
for p.HasMorePages() {
response, err := p.NextPage(ctx, func(options *configservice.Options) {
options.Region = c.Region
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func DeliveryChannels() *schema.Table {
tableName := "aws_config_delivery_channels"
return &schema.Table{
Name: tableName,
Description: `https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeDeliveryChannels.html`,
Description: `https://docs.aws.amazon.com/config/latest/APIReference/API_DeliveryChannel.html`,
Resolver: fetchDeliveryChannels,
Multiplex: client.ServiceAccountRegionMultiplexer(tableName, "config"),
Transform: transformers.TransformWithStruct(&types.DeliveryChannel{}, transformers.WithPrimaryKeys("Name")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func remediationConfigurations() *schema.Table {
tableName := "aws_config_remediation_configurations"
return &schema.Table{
Name: tableName,
Description: `https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeRemediationConfigurations.html`,
Description: `https://docs.aws.amazon.com/config/latest/APIReference/API_RemediationConfiguration.html`,
Resolver: fetchRemediationConfigurations,
Multiplex: client.ServiceAccountRegionMultiplexer(tableName, "config"),
Transform: transformers.TransformWithStruct(&types.RemediationConfiguration{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func RetentionConfigurations() *schema.Table {
tableName := "aws_config_retention_configurations"
return &schema.Table{
Name: tableName,
Description: `https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeRetentionConfigurations.html`,
Description: `https://docs.aws.amazon.com/config/latest/APIReference/API_RetentionConfiguration.html`,
Resolver: fetchRetentionConfigurations,
Multiplex: client.ServiceAccountRegionMultiplexer(tableName, "config"),
Transform: transformers.TransformWithStruct(&types.RetentionConfiguration{},
Expand All @@ -31,8 +31,7 @@ func fetchRetentionConfigurations(ctx context.Context, meta schema.ClientMeta, p
c := meta.(*client.Client)
svc := c.Services().Configservice

input := &configservice.DescribeRetentionConfigurationsInput{}
p := configservice.NewDescribeRetentionConfigurationsPaginator(svc, input)
p := configservice.NewDescribeRetentionConfigurationsPaginator(svc, nil)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a bit of clean-up requested in a previous PR; no functional changes

for p.HasMorePages() {
response, err := p.NextPage(ctx, func(options *configservice.Options) {
options.Region = c.Region
Expand Down
1 change: 1 addition & 0 deletions website/pages/docs/plugins/sources/aws/tables.md

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

29 changes: 29 additions & 0 deletions website/tables/aws/aws_config_config_rule_compliance_details.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Table: aws_config_config_rule_compliance_details

This table shows data for Config Config Rule Compliance Details.

https://docs.aws.amazon.com/config/latest/APIReference/API_EvaluationResult.html

The composite primary key for this table is (**account_id**, **region**).

## Relations

This table depends on [aws_config_config_rules](aws_config_config_rules).

## Columns

| Name | Type |
| ------------- | ------------- |
|_cq_source_name|String|
|_cq_sync_time|Timestamp|
|_cq_id|UUID|
|_cq_parent_id|UUID|
|account_id (PK)|String|
|region (PK)|String|
|config_rule_name|String|
|annotation|String|
|compliance_type|String|
|config_rule_invoked_time|Timestamp|
|evaluation_result_identifier|JSON|
|result_recorded_time|Timestamp|
|result_token|String|
3 changes: 2 additions & 1 deletion website/tables/aws/aws_config_config_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

This table shows data for Config Config Rules.

https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeConfigRules.html
https://docs.aws.amazon.com/config/latest/APIReference/API_ConfigRule.html

The primary key for this table is **arn**.

## Relations

The following tables depend on aws_config_config_rules:
- [aws_config_config_rule_compliance_details](aws_config_config_rule_compliance_details)
- [aws_config_config_rule_compliances](aws_config_config_rule_compliances)
- [aws_config_remediation_configurations](aws_config_remediation_configurations)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This table shows data for Config Configuration Aggregators.

https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeConfigurationAggregators.html
https://docs.aws.amazon.com/config/latest/APIReference/API_ConfigurationAggregator.html

The primary key for this table is **arn**.

Expand Down
2 changes: 1 addition & 1 deletion website/tables/aws/aws_config_delivery_channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This table shows data for Config Delivery Channels.

https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeDeliveryChannels.html
https://docs.aws.amazon.com/config/latest/APIReference/API_DeliveryChannel.html

The composite primary key for this table is (**account_id**, **region**, **name**).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This table shows data for Config Remediation Configurations.

https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeRemediationConfigurations.html
https://docs.aws.amazon.com/config/latest/APIReference/API_RemediationConfiguration.html

The primary key for this table is **arn**.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This table shows data for Config Retention Configurations.

https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeRetentionConfigurations.html
https://docs.aws.amazon.com/config/latest/APIReference/API_RetentionConfiguration.html

The composite primary key for this table is (**account_id**, **region**, **name**).

Expand Down