Skip to content
This repository was archived by the owner on Nov 20, 2025. It is now read-only.
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
)