Skip to content

Add EBS storage to reports #2

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/aws-usage-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,5 +354,22 @@ export class AwsUsageQueriesStack extends cdk.Stack {
}
});

new GlueView(this, "ebsStorageByAccountView", {
columns: [
{ name: "account_id", type: Schema.STRING },
{ name: "volume_type", type: Schema.STRING },
{ name: "usage_gb", type: Schema.DOUBLE },
{ name: "year", type: Schema.INTEGER },
{ name: "month", type: Schema.INTEGER }
],
database: database,
tableName: "monthly_ebs_storage_by_account",
description: "Monthly EBS storage by volume type and account",
statement: fs.readFileSync(path.join(__dirname, "ebsStorageByAccountView.sql")).toString(),
placeHolders: {
sourceTable: sourceTable.tableName
}
});

}
}
29 changes: 29 additions & 0 deletions lib/ebsStorageByAccountView.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
(
SELECT line_item_usage_account_id account_id,
product_volume_api_name volume_type,
sum(line_item_usage_amount) as usage_gb,
year,
month
FROM ${sourceTable}
WHERE product_servicename LIKE '%Amazon Elastic Compute Cloud%'
AND product_usagetype LIKE 'EBS:VolumeUsage%'
GROUP BY line_item_usage_account_id,
product_volume_api_name,
year,
month
)
UNION
(
SELECT line_item_usage_account_id account_id,
product_product_family volume_type,
sum(line_item_usage_amount) as usage_gb,
year,
month
FROM ${sourceTable}
WHERE product_servicename LIKE '%Amazon Elastic Compute Cloud%'
AND product_usagetype LIKE 'EBS:SnapshotUsage%'
GROUP BY line_item_usage_account_id,
product_product_family,
year,
month
)