Skip to content

Commit f252d84

Browse files
Add - create aws_cost.sh script to retrieve monthly cost data
1 parent 12d8918 commit f252d84

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

services/aws_cost.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
###################################################################
4+
# # @version 1.0.0
5+
# # @script aws_cost.sh
6+
# # @author lamhaison
7+
8+
# # @description Description detail about the script
9+
# # @bash_version None
10+
# # @notes None
11+
# # @usage Only use function in the script instead of bash aws_config.sh
12+
# # @date YYYYMMDD
13+
###################################################################
14+
15+
function aws_cost_list_months_later() {
16+
# Default is 6 months
17+
local months=${1:-'6'}
18+
aws ce get-cost-and-usage \
19+
--time-period "Start=$(date -d "${months} months ago" +%Y-%m-01),End=$(date -d "$(date +%Y-%m-01) -1 day" +%Y-%m-%d)" \
20+
--granularity MONTHLY --metrics "UnblendedCost"
21+
}

0 commit comments

Comments
 (0)