Skip to content

Commit

Permalink
Fix Terraform boolean interpretation
Browse files Browse the repository at this point in the history
  • Loading branch information
amarthadan committed Nov 18, 2022
1 parent 9cc4b49 commit 80bf617
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-starfishes-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@api3/airnode-deployer': patch
---

Fix Terraform boolean interpretation
8 changes: 4 additions & 4 deletions packages/airnode-deployer/terraform/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module "run" {

module "startCoordinatorNoGws" {
source = "./modules/function"
count = var.http_gateway_enabled == false && var.http_signed_data_gateway_enabled == false ? 1 : 0
count = !var.http_gateway_enabled && !var.http_signed_data_gateway_enabled ? 1 : 0

name = "${local.name_prefix}-startCoordinator"
handler = "index.startCoordinator"
Expand All @@ -50,7 +50,7 @@ module "startCoordinatorNoGws" {

module "startCoordinatorHttpGw" {
source = "./modules/function"
count = var.http_gateway_enabled == true && var.http_signed_data_gateway_enabled == false ? 1 : 0
count = var.http_gateway_enabled && !var.http_signed_data_gateway_enabled ? 1 : 0

name = "${local.name_prefix}-startCoordinator"
handler = "index.startCoordinator"
Expand All @@ -74,7 +74,7 @@ module "startCoordinatorHttpGw" {

module "startCoordinatorHttpSignedGw" {
source = "./modules/function"
count = var.http_gateway_enabled == false && var.http_signed_data_gateway_enabled == true ? 1 : 0
count = !var.http_gateway_enabled && var.http_signed_data_gateway_enabled ? 1 : 0

name = "${local.name_prefix}-startCoordinator"
handler = "index.startCoordinator"
Expand All @@ -98,7 +98,7 @@ module "startCoordinatorHttpSignedGw" {

module "startCoordinatorBothGws" {
source = "./modules/function"
count = var.http_gateway_enabled == true && var.http_signed_data_gateway_enabled == true ? 1 : 0
count = var.http_gateway_enabled && var.http_signed_data_gateway_enabled ? 1 : 0

name = "${local.name_prefix}-startCoordinator"
handler = "index.startCoordinator"
Expand Down
6 changes: 6 additions & 0 deletions packages/airnode-deployer/terraform/aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,38 @@ variable "handler_dir" {

variable "max_concurrency" {
description = "Maximum amount of concurrent executions for Airnode Run Lambda"
type = number
default = -1
}

variable "disable_concurrency_reservation" {
description = "Flag to disable any concurrency reservations"
type = bool
default = false
}

variable "http_gateway_enabled" {
description = "Flag to enable HTTP Gateway"
type = bool
default = false
}

variable "http_max_concurrency" {
description = "Maximum amount of concurrent executions for Airnode HTTP Gateway Lambda"
type = number
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function#reserved_concurrent_executions
default = -1
}

variable "http_signed_data_gateway_enabled" {
description = "Flag to enable Signed Data Gateway"
type = bool
default = false
}

variable "http_signed_data_max_concurrency" {
description = "Maximum amount of concurrent executions for Airnode Signed Data Gateway Lambda"
type = number
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function#reserved_concurrent_executions
default = -1
}
Expand Down
16 changes: 8 additions & 8 deletions packages/airnode-deployer/terraform/gcp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ module "startCoordinator" {
airnode_bucket = var.airnode_bucket
deployment_bucket_dir = var.deployment_bucket_dir
environment_variables = {
HTTP_GATEWAY_URL = var.http_gateway_enabled == false ? null : "https://${module.httpGw[0].api_url}/${random_uuid.http_path_key.result}"
HTTP_SIGNED_DATA_GATEWAY_URL = var.http_signed_data_gateway_enabled == false ? null : "https://${module.httpSignedGw[0].api_url}${random_uuid.http_signed_data_path_key.result}"
HTTP_GATEWAY_URL = var.http_gateway_enabled ? "https://${module.httpGw[0].api_url}/${random_uuid.http_path_key.result}" : null
HTTP_SIGNED_DATA_GATEWAY_URL = var.http_signed_data_gateway_enabled ? "https://${module.httpSignedGw[0].api_url}${random_uuid.http_signed_data_path_key.result}" : null
AIRNODE_WALLET_PRIVATE_KEY = var.airnode_wallet_private_key
}

Expand All @@ -83,7 +83,7 @@ module "startCoordinator" {
}

resource "google_project_service" "apigateway_api" {
count = var.http_gateway_enabled == false && var.http_signed_data_gateway_enabled == false ? 0 : 1
count = var.http_gateway_enabled || var.http_signed_data_gateway_enabled ? 1 : 0

service = "apigateway.googleapis.com"

Expand All @@ -96,7 +96,7 @@ resource "google_project_service" "apigateway_api" {
}

resource "google_project_service" "servicecontrol_api" {
count = var.http_gateway_enabled == false && var.http_signed_data_gateway_enabled == false ? 0 : 1
count = var.http_gateway_enabled || var.http_signed_data_gateway_enabled ? 1 : 0

service = "servicecontrol.googleapis.com"

Expand All @@ -110,7 +110,7 @@ resource "google_project_service" "servicecontrol_api" {

module "httpReq" {
source = "./modules/function"
count = var.http_gateway_enabled == false ? 0 : 1
count = var.http_gateway_enabled ? 1 : 0

name = "${local.name_prefix}-httpReq"
entry_point = "httpReq"
Expand All @@ -132,7 +132,7 @@ module "httpReq" {

module "httpGw" {
source = "./modules/apigateway"
count = var.http_gateway_enabled == false ? 0 : 1
count = var.http_gateway_enabled ? 1 : 0

name = "${local.name_prefix}-httpGw"
template_file = "./templates/httpGw.yaml.tpl"
Expand All @@ -157,7 +157,7 @@ module "httpGw" {

module "httpSignedReq" {
source = "./modules/function"
count = var.http_signed_data_gateway_enabled == false ? 0 : 1
count = var.http_signed_data_gateway_enabled ? 1 : 0

name = "${local.name_prefix}-httpSignedReq"
entry_point = "httpSignedReq"
Expand All @@ -182,7 +182,7 @@ module "httpSignedReq" {

module "httpSignedGw" {
source = "./modules/apigateway"
count = var.http_signed_data_gateway_enabled == false ? 0 : 1
count = var.http_signed_data_gateway_enabled ? 1 : 0

name = "${local.name_prefix}-httpSignedGw"
template_file = "./templates/httpSignedGw.yaml.tpl"
Expand Down
6 changes: 6 additions & 0 deletions packages/airnode-deployer/terraform/gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,37 @@ variable "handler_dir" {

variable "max_concurrency" {
description = "Maximum amount of concurrent executions for Airnode Run Cloud function"
type = number
default = 0
}

variable "disable_concurrency_reservation" {
description = "Flag to disable any concurrency reservations"
type = bool
default = false
}

variable "http_gateway_enabled" {
description = "Flag to enable HTTP Gateway"
type = bool
default = false
}

variable "http_max_concurrency" {
description = "Maximum amount of concurrent executions for Airnode HTTP Gateway Cloud Function"
type = number
default = 0
}

variable "http_signed_data_gateway_enabled" {
description = "Flag to enable Signed Data Gateway"
type = bool
default = false
}

variable "http_signed_data_max_concurrency" {
description = "Maximum amount of concurrent executions for Airnode Signed Data Gateway Cloud Function"
type = number
default = 0
}

Expand Down

0 comments on commit 80bf617

Please sign in to comment.