From b1d598882f64efb1aa1e4c43899a58e8bfc4adda Mon Sep 17 00:00:00 2001 From: Mark Anderson-Trocme Date: Tue, 15 Nov 2022 09:10:08 -0500 Subject: [PATCH] fix: Support for new AWS region (#15) Co-authored-by: Anton Babenko Closes https://github.com/terraform-aws-modules/terraform-aws-pricing/issues/14 --- examples/pricing-resources/main.tf | 3 ++- modules/pricing/README.md | 1 + modules/pricing/filters.tf | 3 +++ modules/pricing/regions.tf | 2 +- modules/pricing/variables.tf | 6 ++++++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/examples/pricing-resources/main.tf b/examples/pricing-resources/main.tf index 24e9434..60710c5 100644 --- a/examples/pricing-resources/main.tf +++ b/examples/pricing-resources/main.tf @@ -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 diff --git a/modules/pricing/README.md b/modules/pricing/README.md index dd4b400..4057818 100644 --- a/modules/pricing/README.md +++ b/modules/pricing/README.md @@ -67,6 +67,7 @@ No modules. | [debug\_output](#input\_debug\_output) | Whether to populate more output (useful for debug, but increase verbosity and size of tfstate) | `bool` | `false` | no | | [hourly\_price\_precision](#input\_hourly\_price\_precision) | Number of digits after comma in hourly price | `number` | `10` | no | | [monthly\_price\_precision](#input\_monthly\_price\_precision) | Number of digits after comma in monthly price | `number` | `2` | no | +| [query\_all\_regions](#input\_query\_all\_regions) | If true the source will query all regions regardless of availability | `bool` | `true` | no | | [resources](#input\_resources) | Map of all resources to calculate price for | `any` | `{}` | no | ## Outputs diff --git a/modules/pricing/filters.tf b/modules/pricing/filters.tf index abb4904..620ddea 100644 --- a/modules/pricing/filters.tf +++ b/modules/pricing/filters.tf @@ -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" @@ -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" @@ -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" diff --git a/modules/pricing/regions.tf b/modules/pricing/regions.tf index b847661..c8f43b4 100644 --- a/modules/pricing/regions.tf +++ b/modules/pricing/regions.tf @@ -1,5 +1,5 @@ data "aws_regions" "all" { - all_regions = true + all_regions = var.query_all_regions } data "aws_region" "one" { diff --git a/modules/pricing/variables.tf b/modules/pricing/variables.tf index 9eb738c..66acd3c 100644 --- a/modules/pricing/variables.tf +++ b/modules/pricing/variables.tf @@ -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"