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 Terraform boolean interpretation #1542

Merged
merged 1 commit into from
Nov 18, 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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering why it was working back in https://github.com/api3dao/airnode/pull/1418/files#diff-296ebb005304c61b91c2f50aa9a9c697158399ee17503b6a7a6374ebab553a4aR40 (I've also checked by deploying using docker image from that commit).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure tbh 🤷‍♂️

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