-
Notifications
You must be signed in to change notification settings - Fork 103
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 for cost by region monthly #2310
add table for cost by region monthly #2310
Conversation
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.
Hello @razbne, left a few review comments, please take look, thanks!
{Name: "region", Operators: []string{"=", "<>"}, Require: plugin.Optional}, | ||
}, | ||
}, | ||
Columns: costExplorerColumns([]*plugin.Column{ |
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.
Hi @razbne,
Could you please add the missing common columns to this table? These columns are shared across tables.
- For an aggregator connection, the
partition
andaccount_id
columns are important to identify the account associated with the displayed result. - I understand that we can't use the
awsGlobalRegionColumns()
function here since the region column will always show asglobal
. - However, we can manually include it as follows:
Columns: costExplorerColumns([]*plugin.Column{
{
Name: "region",
Description: "The name of the AWS region.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("Dimension1"),
},
// Steampipe common columns
{
Name: "partition",
Type: proto.ColumnType_STRING,
Hydrate: getCommonColumns,
Description: "The AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov).",
},
{
Name: "account_id",
Type: proto.ColumnType_STRING,
Hydrate: getCommonColumns,
Description: "The AWS Account ID in which the resource is located.",
Transform: transform.FromCamel(),
},
}),
for _, keyQual := range d.Table.List.KeyColumns { | ||
filterQual := d.Quals[keyQual.Name] | ||
if filterQual == nil { | ||
continue | ||
} | ||
for _, qual := range filterQual.Quals { | ||
if qual.Value != nil { | ||
value := qual.Value | ||
switch qual.Operator { | ||
case "=": | ||
filter := types.Expression{} | ||
filter.Dimensions = &types.DimensionValues{} | ||
filter.Dimensions.Key = types.Dimension(strings.ToUpper(keyQual.Name)) | ||
filter.Dimensions.Values = []string{value.GetStringValue()} | ||
filters = append(filters, filter) | ||
case "<>": | ||
filter := types.Expression{} | ||
filter.Not = &types.Expression{} | ||
filter.Not.Dimensions = &types.DimensionValues{} | ||
filter.Not.Dimensions.Key = types.Dimension(strings.ToUpper(keyQual.Name)) | ||
filter.Not.Dimensions.Values = []string{value.GetStringValue()} | ||
filters = append(filters, filter) | ||
} | ||
} | ||
} | ||
} |
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.
Please update the local variable name to lowerCamelCase
for consistency across the tables.
for _, keyQual := range d.Table.List.KeyColumns { | |
filterQual := d.Quals[keyQual.Name] | |
if filterQual == nil { | |
continue | |
} | |
for _, qual := range filterQual.Quals { | |
if qual.Value != nil { | |
value := qual.Value | |
switch qual.Operator { | |
case "=": | |
filter := types.Expression{} | |
filter.Dimensions = &types.DimensionValues{} | |
filter.Dimensions.Key = types.Dimension(strings.ToUpper(keyQual.Name)) | |
filter.Dimensions.Values = []string{value.GetStringValue()} | |
filters = append(filters, filter) | |
case "<>": | |
filter := types.Expression{} | |
filter.Not = &types.Expression{} | |
filter.Not.Dimensions = &types.DimensionValues{} | |
filter.Not.Dimensions.Key = types.Dimension(strings.ToUpper(keyQual.Name)) | |
filter.Not.Dimensions.Values = []string{value.GetStringValue()} | |
filters = append(filters, filter) | |
} | |
} | |
} | |
} | |
for _, keyQual := range d.Table.List.KeyColumns { | |
filterQual := d.Quals[keyQual.Name] | |
if filterQual == nil { | |
continue | |
} | |
for _, qual := range filterQual.Quals { | |
if qual.Value != nil { | |
value := qual.Value | |
switch qual.Operator { | |
case "=": | |
filter := types.Expression{} | |
filter.Dimensions = &types.DimensionValues{} | |
filter.Dimensions.Key = types.Dimension(strings.ToUpper(keyQual.Name)) | |
filter.Dimensions.Values = []string{value.GetStringValue()} | |
filters = append(filters, filter) | |
case "<>": | |
filter := types.Expression{} | |
filter.Not = &types.Expression{} | |
filter.Not.Dimensions = &types.DimensionValues{} | |
filter.Not.Dimensions.Key = types.Dimension(strings.ToUpper(keyQual.Name)) | |
filter.Not.Dimensions.Values = []string{value.GetStringValue()} | |
filters = append(filters, filter) | |
} | |
} | |
} | |
} |
limit 10; | ||
``` | ||
|
||
|
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.
limit 10; | ||
``` | ||
|
||
|
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.
Integration test logs
Logs
Example query results
Results