-
Notifications
You must be signed in to change notification settings - Fork 544
feat: Add AWS Config Compliance Details table #10544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1f316db
Add more configuration resources
hermanschaaf 25ed82a
AWS config
hermanschaaf 250749b
Undo
hermanschaaf 1abbe52
Update docs
hermanschaaf 901abbb
Add aws_config_config_rule_compliance_details
hermanschaaf fd8ad40
merge
hermanschaaf 30422cc
Add docs
hermanschaaf 0e5a3d3
Update plugins/source/aws/resources/services/config/config_rule_compl…
hermanschaaf eeb9368
chore: Update code and docs
cq-bot 127b174
Update docs
hermanschaaf 404ea82
Merge branch 'aws-config-compliance-details' of github.com:cloudquery…
hermanschaaf 28f0d1c
Fix PK
hermanschaaf f5eca8d
Merge branch 'main' into aws-config-compliance-details
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
plugins/source/aws/resources/services/config/config_rule_compliance_details.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
26 changes: 26 additions & 0 deletions
26
plugins/source/aws/resources/services/config/config_rule_compliance_details_mock_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
website/tables/aws/aws_config_config_rule_compliance_details.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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