Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Support for new AWS region #15

Merged
merged 4 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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