Skip to content

Commit e4bf04d

Browse files
author
Till Hohenberger
committed
Add EBS storage to reports
Adds report for EBS storage per volume type
1 parent 571d25c commit e4bf04d

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-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

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
SELECT line_item_usage_account_id account_id,
2+
product_volume_api_name volume_type,
3+
sum(line_item_usage_amount) as usage_gb,
4+
year,
5+
month
6+
FROM ${sourceTable}
7+
WHERE product_servicename LIKE '%Amazon Elastic Compute Cloud%'
8+
AND product_usagetype LIKE 'EBS:VolumeUsage%'
9+
GROUP BY line_item_usage_account_id,
10+
product_volume_api_name,
11+
year,
12+
month

0 commit comments

Comments
 (0)