Skip to content

Commit

Permalink
Added tag prefix support for aws/cloud costs (#863)
Browse files Browse the repository at this point in the history
* Removed gcloud auth

* Added tag prefix for cloud costs

* Added tag prefix for cloud costs

* Fixes

* Fixes
  • Loading branch information
jdesouza authored Dec 28, 2023
1 parent 4ca8d30 commit 8d32f26
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions plugins/aws-costs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.4.0
* Added tag prefix

## 1.3.0
* Added new fields line_item_usage_amount, line_item_operation, product_product_family

Expand Down
4 changes: 3 additions & 1 deletion plugins/aws-costs/aws-costs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cat << EOF
usage: awscosts \
--database <database name> \
--table <table name> \
--tagprefix <tag prefix> \
--tagkey <tag key> \
--tagvalue <tag value> \
--catalog <catalog> \
Expand All @@ -24,6 +25,7 @@ EOF
}

tagkey=''
tagprefix=''
tagvalue=''
database=''
table=''
Expand Down Expand Up @@ -90,7 +92,7 @@ queryResults=$(aws athena start-query-execution \
FROM \
"$database"."$table" \
WHERE \
resource_tags_user_$tagkey='$tagvalue' \
$tagprefix$tagkey='$tagvalue' \
AND line_item_usage_end_date > timestamp '$initial_date_time' \
AND line_item_usage_end_date <= timestamp '$final_date_time' \
GROUP BY 1,2,4,5,6,7,8,11,12
Expand Down
2 changes: 1 addition & 1 deletion plugins/aws-costs/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
1.4.0
3 changes: 3 additions & 0 deletions plugins/cloud-costs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.1.8
* Added tag prefix

## 0.1.7
* Removing --quiet option

Expand Down
6 changes: 5 additions & 1 deletion plugins/cloud-costs/cloud-costs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ usage()
cat << EOF
usage: cloud-costs \
--provider <cloud provider - aws is default>
--tagprefix <tag prefix - optional for aws, not used for GCP> \
--tagkey <tag key - required for AWS, optional for GCP> \
--tagvalue <tag value - required for AWS and GCP> \
--database <database name - required for AWS> \
Expand Down Expand Up @@ -49,6 +50,9 @@ while [ ! $# -eq 0 ]; do
provider)
provider=${2}
;;
tagprefix)
tagkey=${2}
;;
tagkey)
tagkey=${2}
;;
Expand Down Expand Up @@ -116,7 +120,7 @@ if [[ "$provider" = "aws" ]]; then
FROM \
"$database"."$table" \
WHERE \
resource_tags_user_$tagkey='$tagvalue' \
$tagprefix$tagkey='$tagvalue' \
AND line_item_usage_end_date > timestamp '$initial_date_time' \
AND line_item_usage_end_date <= timestamp '$final_date_time' \
GROUP BY 1,2,4,5,6,7,8,11,12
Expand Down
2 changes: 1 addition & 1 deletion plugins/cloud-costs/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.7
0.1.8

0 comments on commit 8d32f26

Please sign in to comment.