-
Notifications
You must be signed in to change notification settings - Fork 108
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
Add table aws_trusted_advisor_check_summary Closes #1831 #1978
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
da32449
Add table aws_trusted_advisor_check_summary Closes #1831
ParthaI 31fa1c5
Added doc for the table aws_trusted_advisor_check_summary
ParthaI ee88c62
Update aws/table_aws_trusted_advisor_check_summary.go
ParthaI 2c1e1a3
Update aws/table_aws_trusted_advisor_check_summary.go
ParthaI 9b49929
Update docs/tables/aws_trusted_advisor_check_summary.md
ParthaI 1a6e5eb
Update docs/tables/aws_trusted_advisor_check_summary.md
ParthaI 0739817
Update docs/tables/aws_trusted_advisor_check_summary.md
ParthaI dc50854
Resolved merge conflict
ParthaI 12c0f15
Update the doc to match steampipe latest doc format
ParthaI 0d8280a
Update service.go
misraved 8911e19
Updated the optional quals check logic
ParthaI c49cabf
Merge branch 'issue-1831' of github.com:turbot/steampipe-plugin-aws i…
ParthaI bb4b8aa
made the language column as require qual for the table
ParthaI 4c27e02
Updated the doc example query
ParthaI 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 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 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 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,200 @@ | ||
package aws | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/support" | ||
"github.com/aws/aws-sdk-go-v2/service/support/types" | ||
|
||
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto" | ||
"github.com/turbot/steampipe-plugin-sdk/v5/plugin" | ||
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform" | ||
) | ||
|
||
//// TABLE DEFINITION | ||
|
||
func tableAwsTrustedAdvisorCheckSummary(_ context.Context) *plugin.Table { | ||
return &plugin.Table{ | ||
Name: "aws_trusted_advisor_check_summary", | ||
Description: "AWS Trusted Advisor Check Summary", | ||
Get: &plugin.GetConfig{ | ||
KeyColumns: plugin.SingleColumn("check_id"), | ||
Hydrate: getTrustedAdvisorCheckSummary, | ||
Tags: map[string]string{"service": "support", "action": "DescribeTrustedAdvisorCheckSummaries"}, | ||
}, | ||
List: &plugin.ListConfig{ | ||
Hydrate: listTrustedAdvisorCheckSummaries, | ||
Tags: map[string]string{"service": "support", "action": "DescribeTrustedAdvisorChecks"}, | ||
}, | ||
HydrateConfig: []plugin.HydrateConfig{ | ||
{ | ||
Func: getTrustedAdvisorCheckSummary, | ||
Tags: map[string]string{"service": "support", "action": "DescribeTrustedAdvisorCheckSummaries"}, | ||
}, | ||
}, | ||
Columns: awsAccountColumns([]*plugin.Column{ | ||
{ | ||
Name: "name", | ||
Description: "The display name for the Trusted Advisor check.", | ||
Type: proto.ColumnType_STRING, | ||
}, | ||
{ | ||
Name: "check_id", | ||
Description: "The unique identifier for the Trusted Advisor check.", | ||
Type: proto.ColumnType_STRING, | ||
Transform: transform.FromField("Id", "CheckId"), | ||
}, | ||
{ | ||
Name: "category", | ||
Description: "The category of the Trusted Advisor check.", | ||
Type: proto.ColumnType_STRING, | ||
}, | ||
{ | ||
Name: "description", | ||
Description: "The description of the Trusted Advisor check, which includes the alert criteria and recommended operations (contains HTML markup).", | ||
Type: proto.ColumnType_STRING, | ||
}, | ||
{ | ||
Name: "status", | ||
Description: "The alert status of the check: 'ok' (green), 'warning' (yellow), 'error' (red), or 'not_available'.", | ||
Type: proto.ColumnType_STRING, | ||
Hydrate: getTrustedAdvisorCheckSummary, | ||
}, | ||
{ | ||
Name: "timestamp", | ||
Description: "The time of the last refresh of the check.", | ||
Type: proto.ColumnType_TIMESTAMP, | ||
Hydrate: getTrustedAdvisorCheckSummary, | ||
}, | ||
{ | ||
Name: "resources_flagged", | ||
Description: "The number of Amazon Web Services resources that were flagged (listed) by the Trusted Advisor check.", | ||
Type: proto.ColumnType_INT, | ||
Hydrate: getTrustedAdvisorCheckSummary, | ||
Transform: transform.FromField("ResourcesSummary.ResourcesFlagged"), | ||
}, | ||
{ | ||
Name: "resources_ignored", | ||
Description: "The number of Amazon Web Services resources ignored by Trusted Advisor because information was unavailable.", | ||
Type: proto.ColumnType_INT, | ||
Hydrate: getTrustedAdvisorCheckSummary, | ||
Transform: transform.FromField("ResourcesSummary.ResourcesIgnored"), | ||
}, | ||
{ | ||
Name: "resources_processed", | ||
Description: "The number of Amazon Web Services resources that were analyzed by the Trusted Advisor check.", | ||
Type: proto.ColumnType_INT, | ||
Hydrate: getTrustedAdvisorCheckSummary, | ||
Transform: transform.FromField("ResourcesSummary.ResourcesProcessed"), | ||
}, | ||
{ | ||
Name: "resources_suppressed", | ||
Description: "The number of Amazon Web Services resources ignored by Trusted Advisor because they were marked as suppressed by the user.", | ||
Type: proto.ColumnType_INT, | ||
Hydrate: getTrustedAdvisorCheckSummary, | ||
Transform: transform.FromField("ResourcesSummary.ResourcesSuppressed"), | ||
}, | ||
{ | ||
Name: "category_specific_summary", | ||
Description: "Summary information that relates to the category of the check. Cost Optimizing is the only category that is currently supported.", | ||
Type: proto.ColumnType_JSON, | ||
Hydrate: getTrustedAdvisorCheckSummary, | ||
}, | ||
{ | ||
Name: "metadata", | ||
Description: "The column headings for the data returned by the Trusted Advisor check. The order of the headings corresponds to the order of the data in the Metadata element of the TrustedAdvisorResourceDetail for the check. Metadata contains all the data that is shown in the Excel download, even in those cases where the UI shows just summary data.", | ||
Type: proto.ColumnType_JSON, | ||
}, | ||
|
||
// Steampipe standard columns | ||
{ | ||
Name: "title", | ||
Description: resourceInterfaceDescription("title"), | ||
Type: proto.ColumnType_STRING, | ||
Transform: transform.FromField("Name"), | ||
}, | ||
}), | ||
} | ||
} | ||
|
||
//// LIST FUNCTION | ||
|
||
func listTrustedAdvisorCheckSummaries(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { | ||
// Create session | ||
svc, err := SupportClient(ctx, d) | ||
if err != nil { | ||
plugin.Logger(ctx).Error("aws_trusted_advisor_check_summary.listTrustedAdvisorCheckSummaries", "client_error", err) | ||
return nil, err | ||
} | ||
if svc == nil { | ||
return nil, nil | ||
} | ||
|
||
input := &support.DescribeTrustedAdvisorChecksInput{ | ||
Language: aws.String("en"), | ||
} | ||
|
||
// List call | ||
result, err := svc.DescribeTrustedAdvisorChecks(ctx, input) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the API support pagination? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the API does not support pagination |
||
if err != nil { | ||
plugin.Logger(ctx).Error("aws_trusted_advisor_check_summary.listTrustedAdvisorCheckSummaries", "api_error", err) | ||
return nil, err | ||
} | ||
|
||
for _, check := range result.Checks { | ||
d.StreamListItem(ctx, check) | ||
|
||
// Context can be cancelled due to manual cancellation or the limit has been hit | ||
if d.RowsRemaining(ctx) == 0 { | ||
return nil, nil | ||
} | ||
} | ||
|
||
return nil, err | ||
} | ||
|
||
//// HYDRATE FUNCTIONS | ||
|
||
func getTrustedAdvisorCheckSummary(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { | ||
|
||
checkId := "" | ||
|
||
if h.Item != nil { | ||
checkSummary := h.Item.(types.TrustedAdvisorCheckDescription) | ||
checkId = *checkSummary.Id | ||
} else if d.EqualsQualString("check_id") != "" { | ||
checkId = d.EqualsQualString("check_id") | ||
} | ||
ParthaI marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Empty check | ||
if checkId == "" { | ||
return nil, nil | ||
} | ||
|
||
// Create session | ||
svc, err := SupportClient(ctx, d) | ||
if err != nil { | ||
plugin.Logger(ctx).Error("aws_trusted_advisor_check_summary.getTrustedAdvisorCheckSummary", "client_error", err) | ||
return nil, err | ||
} | ||
if svc == nil { | ||
return nil, nil | ||
} | ||
|
||
input := &support.DescribeTrustedAdvisorCheckSummariesInput{ | ||
CheckIds: []*string{aws.String(checkId)}, | ||
} | ||
|
||
// Get call | ||
result, err := svc.DescribeTrustedAdvisorCheckSummaries(ctx, input) | ||
if err != nil { | ||
plugin.Logger(ctx).Error("aws_trusted_advisor_check_summary.getTrustedAdvisorCheckSummary", "api_error", err) | ||
return nil, err | ||
} | ||
|
||
if result != nil && len(result.Summaries) > 0 { | ||
return result.Summaries[0], nil | ||
} | ||
return nil, nil | ||
} |
This file contains 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,126 @@ | ||
--- | ||
title: "Steampipe Table: aws_trusted_advisor_check_summary - Query AWS Trusted Advisor Check Summaries using SQL" | ||
description: "A Trusted Advisor check is a specific evaluation or assessment performed by Trusted Advisor in different categories. These checks cover various areas, including cost optimization, security, performance, and fault tolerance. Each check examines a specific aspect of your AWS resources and provides recommendations for improvement." | ||
--- | ||
|
||
# Table: aws_trusted_advisor_check_summary - Query AWS Trusted Advisor Check Summaries using SQL | ||
|
||
A Trusted Advisor check is a specific evaluation or assessment performed by Trusted Advisor in different categories. These checks cover various areas, including cost optimization, security, performance, and fault tolerance. Each check examines a specific aspect of your AWS resources and provides recommendations for improvement. | ||
|
||
## Table Usage Guide | ||
|
||
The `aws_trusted_advisor_check_summary` table in Steampipe allows users to query information about AWS Trusted Advisor Check Summaries. These summaries provide insights into the status and details of Trusted Advisor checks, including the check name, check ID, category, description, status, timestamp, and the number of resources flagged, ignored, processed, and suppressed. | ||
|
||
ParthaI marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Examples | ||
|
||
### Basic info | ||
Retrieve basic information about AWS Trusted Advisor Check Summaries, including the check name, check ID, category, description, status, timestamp, and the number of resources flagged. | ||
|
||
```sql+postgres | ||
select | ||
name, | ||
check_id, | ||
category, | ||
description, | ||
status, | ||
timestamp, | ||
resources_flagged | ||
from | ||
aws_trusted_advisor_check_summary; | ||
``` | ||
|
||
ParthaI marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```sql+sqlite | ||
select | ||
name, | ||
check_id, | ||
category, | ||
description, | ||
status, | ||
timestamp, | ||
resources_flagged | ||
from | ||
aws_trusted_advisor_check_summary; | ||
``` | ||
|
||
### Get error check summaries | ||
Retrieve AWS Trusted Advisor Check Summaries with an "error" status. This query helps you identify checks that require attention due to errors. | ||
|
||
```sql+postgres | ||
select | ||
name, | ||
check_id, | ||
category, | ||
status | ||
from | ||
aws_trusted_advisor_check_summary | ||
where | ||
status = 'error'; | ||
``` | ||
|
||
```sql+sqlite | ||
select | ||
name, | ||
check_id, | ||
category, | ||
status | ||
from | ||
aws_trusted_advisor_check_summary | ||
where | ||
status = 'error'; | ||
``` | ||
|
||
### Get check summaries for the last 5 days | ||
Retrieve AWS Trusted Advisor Check Summaries from the last 5 days. This query allows you to review recent check summaries and their details. | ||
|
||
```sql+postgres | ||
select | ||
name, | ||
check_id, | ||
description, | ||
status, | ||
timestamp | ||
from | ||
aws_trusted_advisor_check_summary | ||
where | ||
timestamp >= now() - interval '5 day'; | ||
``` | ||
|
||
```sql+sqlite | ||
select | ||
name, | ||
check_id, | ||
description, | ||
status, | ||
timestamp | ||
from | ||
aws_trusted_advisor_check_summary | ||
where | ||
timestamp >= datetime('now', '-5 day'); | ||
``` | ||
|
||
### Get resource summaries of each check | ||
Retrieve resource summaries for each AWS Trusted Advisor Check. This includes the number of resources flagged, ignored, processed, and suppressed for each check. | ||
|
||
```sql+postgres | ||
select | ||
name, | ||
check_id, | ||
resources_flagged, | ||
resources_ignored, | ||
resources_processed, | ||
resources_suppressed | ||
from | ||
aws_trusted_advisor_check_summary; | ||
``` | ||
|
||
```sql+sqlite | ||
select | ||
name, | ||
check_id, | ||
resources_flagged, | ||
resources_ignored, | ||
resources_processed, | ||
resources_suppressed | ||
from | ||
aws_trusted_advisor_check_summary; | ||
``` |
This file contains 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 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
Oops, something went wrong.
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.
@ParthaI can this be considered as an optional qual?
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.
@misraved, According to the API documentation, this parameter is necessary for making the API call. We can designate it as a required qualifier or as an optional qualifier with the default value set to
en
(if the user doesn't provide any value in the WHERE clause for it). By the way, the API does not return the 'Language' property in its response.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.
@ParthaI I think we can update the table to use
language
as a required qual to best replicate the API behaviour.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.
Updated, the PR by making the language column as required qual.