Skip to content

Commit a57d957

Browse files
author
Till Hohenberger
committed
Add EBS storage to reports
Adds report for EBS storage per volume type Also show Snapshot Storage.
1 parent 571d25c commit a57d957

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

lib/aws-usage-queries.ts

+17
Original file line numberDiff line numberDiff line change
@@ -354,5 +354,22 @@ export class AwsUsageQueriesStack extends cdk.Stack {
354354
}
355355
});
356356

357+
new GlueView(this, "ebsStorageByAccountView", {
358+
columns: [
359+
{ name: "account_id", type: Schema.STRING },
360+
{ name: "volume_type", type: Schema.STRING },
361+
{ name: "usage_gb", type: Schema.DOUBLE },
362+
{ name: "year", type: Schema.INTEGER },
363+
{ name: "month", type: Schema.INTEGER }
364+
],
365+
database: database,
366+
tableName: "monthly_ebs_storage_by_account",
367+
description: "Monthly EBS storage by volume type and account",
368+
statement: fs.readFileSync(path.join(__dirname, "ebsStorageByAccountView.sql")).toString(),
369+
placeHolders: {
370+
sourceTable: sourceTable.tableName
371+
}
372+
});
373+
357374
}
358375
}

lib/ebsStorageByAccountView.sql

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
(
2+
SELECT line_item_usage_account_id account_id,
3+
product_volume_api_name volume_type,
4+
sum(line_item_usage_amount) as usage_gb,
5+
year,
6+
month
7+
FROM ${sourceTable}
8+
WHERE product_servicename LIKE '%Amazon Elastic Compute Cloud%'
9+
AND product_usagetype LIKE 'EBS:VolumeUsage%'
10+
GROUP BY line_item_usage_account_id,
11+
product_volume_api_name,
12+
year,
13+
month
14+
)
15+
UNION
16+
(
17+
SELECT line_item_usage_account_id account_id,
18+
product_product_family volume_type,
19+
sum(line_item_usage_amount) as usage_gb,
20+
year,
21+
month
22+
FROM ${sourceTable}
23+
WHERE product_servicename LIKE '%Amazon Elastic Compute Cloud%'
24+
AND product_usagetype LIKE 'EBS:SnapshotUsage%'
25+
GROUP BY line_item_usage_account_id,
26+
product_product_family,
27+
year,
28+
month
29+
)

0 commit comments

Comments
 (0)