Last active
March 25, 2019 13:54
-
-
Save softprops/d38e34d557c58f2cfba8caf77f727833 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# discover what values you can use for a given service in the last 3 months | |
# | |
# aws ce get-dimension-values \ | |
# --dimension SERVICE \ | |
# --time-period Start=$(date -v-3m +%Y-%m-01),End=$(date +%Y-%m-01) \ | |
# --query 'DimensionValues[*].Value' | |
# last 3 months of ecr usage/spend | |
# typically this is grouped into DataTransfer-Out-Bytes and TimedStorage-ByteHrs | |
# where TimedStorage-ByteHrs is the majority of your spend for larger docker images | |
# see ecr pricing page for more details on costs https://aws.amazon.com/ecr/pricing/ | |
aws ce get-cost-and-usage \ | |
--time-period Start=$(date -v-3m +%Y-%m-01),End=$(date +%Y-%m-01) \ | |
--granularity MONTHLY \ | |
--metrics "UsageQuantity" "AmortizedCost" \ | |
--group-by Type=DIMENSION,Key=USAGE_TYPE \ | |
--filter "$(cat <<'EOF' | |
{ | |
"Dimensions": { | |
"Key": "SERVICE", | |
"Values": ["Amazon EC2 Container Registry (ECR)"] | |
} | |
} | |
EOF | |
)" --query "ResultsByTime[*]" --output json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment