Skip to content

Commit

Permalink
fix: Support for new AWS region (#15)
Browse files Browse the repository at this point in the history
Co-authored-by: Anton Babenko <anton@antonbabenko.com>
Closes #14
  • Loading branch information
Mark Anderson-Trocme committed Nov 15, 2022
1 parent df3ccd8 commit b1d5988
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion examples/pricing-resources/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ provider "aws" {
module "pricing" {
source = "../../modules/pricing"

debug_output = true
debug_output = true
query_all_regions = false

resources = {
"aws_instance.this#3" = { # 3 instances
Expand Down
1 change: 1 addition & 0 deletions modules/pricing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ No modules.
| <a name="input_debug_output"></a> [debug\_output](#input\_debug\_output) | Whether to populate more output (useful for debug, but increase verbosity and size of tfstate) | `bool` | `false` | no |
| <a name="input_hourly_price_precision"></a> [hourly\_price\_precision](#input\_hourly\_price\_precision) | Number of digits after comma in hourly price | `number` | `10` | no |
| <a name="input_monthly_price_precision"></a> [monthly\_price\_precision](#input\_monthly\_price\_precision) | Number of digits after comma in monthly price | `number` | `2` | no |
| <a name="input_query_all_regions"></a> [query\_all\_regions](#input\_query\_all\_regions) | If true the source will query all regions regardless of availability | `bool` | `true` | no |
| <a name="input_resources"></a> [resources](#input\_resources) | Map of all resources to calculate price for | `any` | `{}` | no |

## Outputs
Expand Down
3 changes: 3 additions & 0 deletions modules/pricing/filters.tf
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ locals {
ap-southeast-3 = "APS3-NatGateway-Hours"
ca-central-1 = "CAN1-NatGateway-Hours"
eu-central-1 = "EUC1-NatGateway-Hours"
eu-central-2 = "EUC2-NatGateway-Hours"
eu-west-1 = "EU-NatGateway-Hours"
eu-west-2 = "EUW2-NatGateway-Hours"
eu-west-3 = "EUW3-NatGateway-Hours"
Expand Down Expand Up @@ -310,6 +311,7 @@ locals {
ap-southeast-3 = "APS3-LoadBalancerUsage"
ca-central-1 = "CAN1-LoadBalancerUsage"
eu-central-1 = "EUC1-LoadBalancerUsage"
eu-central-2 = "EUC2-LoadBalancerUsage"
eu-west-1 = "EU-LoadBalancerUsage"
eu-west-2 = "EUW2-LoadBalancerUsage"
eu-west-3 = "EUW3-LoadBalancerUsage"
Expand Down Expand Up @@ -341,6 +343,7 @@ locals {
ap-southeast-3 = "APS3-EBS:SnapshotUsage"
ca-central-1 = "CAN1-EBS:SnapshotUsage"
eu-central-1 = "EUC1-EBS:SnapshotUsage"
eu-central-2 = "EUC2-EBS:SnapshotUsage"
eu-west-1 = "EU-EBS:SnapshotUsage"
eu-west-2 = "EUW2-EBS:SnapshotUsage"
eu-west-3 = "EUW3-EBS:SnapshotUsage"
Expand Down
2 changes: 1 addition & 1 deletion modules/pricing/regions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data "aws_regions" "all" {
all_regions = true
all_regions = var.query_all_regions
}

data "aws_region" "one" {
Expand Down
6 changes: 6 additions & 0 deletions modules/pricing/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ variable "monthly_price_precision" {
default = 2
}

variable "query_all_regions" {
description = "If true the source will query all regions regardless of availability"
type = bool
default = true
}

# Defaults
variable "aws_default_region" {
description = "Default AWS region to use for resources (if not set) when asking AWS Pricing API"
Expand Down

0 comments on commit b1d5988

Please sign in to comment.