Skip to content

Commit 5ac5019

Browse files
authored
feat: Added many filters and updates (#1)
1 parent fe9913c commit 5ac5019

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+10362
-101
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,34 @@ This is not an official HashiCorp product.
2020
- [x] Optionally, using [cost.modules.tf](https://cost.modules.tf/)
2121
- [x] Can be executed on restricted CI/CD platforms where Terraform can run
2222

23+
24+
## Supported resources
25+
26+
1. EC2 instances (on-demand) and Autoscaling Groups (Launch Configurations and Launch Templates):
27+
- [x] aws_instance
28+
- [ ] aws_autoscaling_group
29+
- [ ] aws_launch_configuration
30+
- [ ] aws_launch_template
31+
32+
2. EC2 Fleets (on-demand)
33+
- [ ] aws_ec2_fleet
34+
35+
3. EBS Volumes, Snapshots, Snapshot Copies
36+
- [x] aws_ebs_volume
37+
- [x] aws_ebs_snapshot
38+
- [x] aws_ebs_snapshot_copy
39+
40+
4. Elastic Load Balancing (ELB, ALB, NLB)
41+
- [x] aws_elb
42+
- [x] aws_alb / aws_lb
43+
44+
5. NAT Gateways
45+
- [x] aws_nat_gateway
46+
47+
6. Redshift Clusters
48+
- [x] aws_redshift_cluster
49+
50+
2351
## Usages
2452

2553
### Using AWS Pricing API: Terraform state or plan as JSON
@@ -134,8 +162,9 @@ When you use this type of backend, there is no way to run `terraform output`.
134162
135163
### Known issues/limitations
136164
165+
1. Autoscaling groups resources
137166
1. When changing values price is sometimes higher after the first run because it is calculated based on keys and there can be some previous keys. Solution is to update code to include some unique key/prefix. Or just disable terraform state (no state = no past).
138-
2. At some point later, maybe add support for other providers like [Azure](http://davecallan.com/azure-price-api-examples/) and [Google Cloud](https://stackoverflow.com/questions/59048071/how-to-get-gcp-pricing-list-from-catalogue-api)
167+
1. At some point later, maybe add support for other providers like [Azure](http://davecallan.com/azure-price-api-examples/) and [Google Cloud](https://stackoverflow.com/questions/59048071/how-to-get-gcp-pricing-list-from-catalogue-api)
139168
140169
141170
## Examples

dev/aws_pricing.md

Lines changed: 280 additions & 6 deletions
Large diffs are not rendered by default.

dev/calculate_results.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
# Run all AWS CLI commands and verify that 1 result is returned
4+
# Make sure to run: terraform apply (with `local.debug_output = true` to populate aws_cli_commands)
5+
6+
set +e # do not exit on bad exit code
7+
8+
aws_cli_commands=$(terraform output -json aws_cli_commands | jq -r '.[] | gsub("[\\n\\t]"; "")')
9+
10+
while IFS=$'\n' read -ra commands; do
11+
for one in "${commands[@]}"; do
12+
printf '%*s\n' 58 | tr ' ' '-'
13+
echo $one
14+
result=$(/bin/bash -c "$one")
15+
exit_code=$?
16+
17+
if [ $exit_code -ne 0 ]; then
18+
echo "Error!"
19+
continue
20+
fi
21+
22+
products=$(echo $result | jq -r '.PriceList | length')
23+
24+
if [ $products -eq 0 ]; then
25+
echo "0 products found. Expected 1!"
26+
elif [ $products -ne 1 ]; then
27+
echo "$products products found. Expected 1!"
28+
echo $result | jq -r '.PriceList[0] | fromjson | .product'
29+
echo $result | jq -r '.PriceList[1] | fromjson | .product'
30+
else
31+
echo "OK!"
32+
echo $result | jq -r '.PriceList[0] | fromjson | .terms.OnDemand[].priceDimensions[].pricePerUnit.USD'
33+
echo $result | jq -r '.PriceList[0] | fromjson | .product'
34+
fi
35+
36+
done
37+
done <<< "$aws_cli_commands"
38+

dev/filters.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)