diff --git a/README.md b/README.md index 4faefc306f..88517937d3 100644 --- a/README.md +++ b/README.md @@ -428,6 +428,7 @@ In case the setup does not work as intended follow the trace of events: | [kms\_key\_arn](#input\_kms\_key\_arn) | Optional CMK Key ARN to be used for Parameter Store. This key must be in the current account. | `string` | `null` | no | | [lambda\_principals](#input\_lambda\_principals) | (Optional) add extra principals to the role created for execution of the lambda, e.g. for local testing. |
list(object({| `[]` | no | | [lambda\_runtime](#input\_lambda\_runtime) | AWS Lambda runtime. | `string` | `"nodejs14.x"` | no | +| [lambda\_architecture](#input\_lambda\_architecture) | AWS Lambda architecture. | `string` | `"x86_64"` | no | | [lambda\_s3\_bucket](#input\_lambda\_s3\_bucket) | S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly. | `any` | `null` | no | | [lambda\_security\_group\_ids](#input\_lambda\_security\_group\_ids) | List of security group IDs associated with the Lambda function. | `list(string)` | `[]` | no | | [lambda\_subnet\_ids](#input\_lambda\_subnet\_ids) | List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`. | `list(string)` | `[]` | no | diff --git a/main.tf b/main.tf index f03dd0bad4..3fa6f4baa8 100644 --- a/main.tf +++ b/main.tf @@ -103,6 +103,7 @@ module "webhook" { webhook_lambda_s3_key = var.webhook_lambda_s3_key webhook_lambda_s3_object_version = var.webhook_lambda_s3_object_version lambda_runtime = var.lambda_runtime + lambda_architecture = var.lambda_architecture lambda_zip = var.webhook_lambda_zip lambda_timeout = var.webhook_lambda_timeout logging_retention_in_days = var.logging_retention_in_days @@ -169,6 +170,7 @@ module "runners" { runners_lambda_s3_key = var.runners_lambda_s3_key runners_lambda_s3_object_version = var.runners_lambda_s3_object_version lambda_runtime = var.lambda_runtime + lambda_architecture = var.lambda_architecture lambda_zip = var.runners_lambda_zip lambda_timeout_scale_up = var.runners_scale_up_lambda_timeout lambda_timeout_scale_down = var.runners_scale_down_lambda_timeout @@ -229,6 +231,7 @@ module "runner_binaries" { syncer_lambda_s3_key = var.syncer_lambda_s3_key syncer_lambda_s3_object_version = var.syncer_lambda_s3_object_version lambda_runtime = var.lambda_runtime + lambda_architecture = var.lambda_architecture lambda_zip = var.runner_binaries_syncer_lambda_zip lambda_timeout = var.runner_binaries_syncer_lambda_timeout logging_retention_in_days = var.logging_retention_in_days diff --git a/modules/runner-binaries-syncer/runner-binaries-syncer.tf b/modules/runner-binaries-syncer/runner-binaries-syncer.tf index 3ea75b0750..af82c29e2f 100644 --- a/modules/runner-binaries-syncer/runner-binaries-syncer.tf +++ b/modules/runner-binaries-syncer/runner-binaries-syncer.tf @@ -19,6 +19,7 @@ resource "aws_lambda_function" "syncer" { runtime = var.lambda_runtime timeout = var.lambda_timeout memory_size = 256 + architectures = [var.lambda_architecture] environment { variables = { diff --git a/modules/runner-binaries-syncer/variables.tf b/modules/runner-binaries-syncer/variables.tf index 42a9d28be1..05841a43bf 100644 --- a/modules/runner-binaries-syncer/variables.tf +++ b/modules/runner-binaries-syncer/variables.tf @@ -187,3 +187,13 @@ variable "lambda_runtime" { type = string default = "nodejs14.x" } + +variable "lambda_architecture" { + description = "AWS Lambda architecture. Lambda functions using Graviton processors ('arm64') tend to have better price/performance than 'x86_64' functions. " + type = string + default = "x86_64" + validation { + condition = contains(["arm64", "x86_64"], var.lambda_architecture) + error_message = "`lambda_architecture` value is not valid, valid values are: `arm64` and `x86_64`." + } +} \ No newline at end of file diff --git a/modules/runners/pool.tf b/modules/runners/pool.tf index 53c70491fa..5200b114e4 100644 --- a/modules/runners/pool.tf +++ b/modules/runners/pool.tf @@ -26,6 +26,7 @@ module "pool" { s3_object_version = var.runners_lambda_s3_object_version security_group_ids = var.lambda_security_group_ids subnet_ids = var.lambda_subnet_ids + architecture = var.lambda_architecture runtime = var.lambda_runtime timeout = var.pool_lambda_timeout zip = local.lambda_zip diff --git a/modules/runners/pool/main.tf b/modules/runners/pool/main.tf index be9970b200..e0d0fb9976 100644 --- a/modules/runners/pool/main.tf +++ b/modules/runners/pool/main.tf @@ -8,6 +8,7 @@ resource "aws_lambda_function" "pool" { function_name = "${var.config.prefix}-pool" role = aws_iam_role.pool.arn handler = "index.adjustPool" + architectures = [var.config.lambda.architecture] runtime = var.config.lambda.runtime timeout = var.config.lambda.timeout reserved_concurrent_executions = var.config.lambda.reserved_concurrent_executions diff --git a/modules/runners/pool/variables.tf b/modules/runners/pool/variables.tf index e6b69221d3..064da4a70c 100644 --- a/modules/runners/pool/variables.tf +++ b/modules/runners/pool/variables.tf @@ -11,6 +11,7 @@ variable "config" { s3_object_version = string security_group_ids = list(string) runtime = string + architecture = string timeout = number zip = string subnet_ids = list(string) diff --git a/modules/runners/scale-down.tf b/modules/runners/scale-down.tf index 3746c45aea..08181485c8 100644 --- a/modules/runners/scale-down.tf +++ b/modules/runners/scale-down.tf @@ -18,6 +18,7 @@ resource "aws_lambda_function" "scale_down" { timeout = var.lambda_timeout_scale_down tags = local.tags memory_size = 512 + architectures = [var.lambda_architecture] environment { variables = { diff --git a/modules/runners/scale-up.tf b/modules/runners/scale-up.tf index 85528656d3..534b7daa64 100644 --- a/modules/runners/scale-up.tf +++ b/modules/runners/scale-up.tf @@ -12,6 +12,7 @@ resource "aws_lambda_function" "scale_up" { reserved_concurrent_executions = var.scale_up_reserved_concurrent_executions memory_size = 512 tags = local.tags + architectures = [var.lambda_architecture] environment { variables = { diff --git a/modules/runners/variables.tf b/modules/runners/variables.tf index 093a5e4b1d..1b7d264610 100644 --- a/modules/runners/variables.tf +++ b/modules/runners/variables.tf @@ -551,3 +551,13 @@ variable "lambda_runtime" { type = string default = "nodejs14.x" } + +variable "lambda_architecture" { + description = "AWS Lambda architecture. Lambda functions using Graviton processors ('arm64') tend to have better price/performance than 'x86_64' functions. " + type = string + default = "x86_64" + validation { + condition = contains(["arm64", "x86_64"], var.lambda_architecture) + error_message = "`lambda_architecture` value is not valid, valid values are: `arm64` and `x86_64`." + } +} \ No newline at end of file diff --git a/modules/webhook/variables.tf b/modules/webhook/variables.tf index 1bb237408a..4fbb825c1a 100644 --- a/modules/webhook/variables.tf +++ b/modules/webhook/variables.tf @@ -162,3 +162,13 @@ variable "lambda_runtime" { type = string default = "nodejs14.x" } + +variable "lambda_architecture" { + description = "AWS Lambda architecture. Lambda functions using Graviton processors ('arm64') tend to have better price/performance than 'x86_64' functions. " + type = string + default = "x86_64" + validation { + condition = contains(["arm64", "x86_64"], var.lambda_architecture) + error_message = "`lambda_architecture` value is not valid, valid values are: `arm64` and `x86_64`." + } +} \ No newline at end of file diff --git a/modules/webhook/webhook.tf b/modules/webhook/webhook.tf index 003d02e455..ac9939a1f5 100644 --- a/modules/webhook/webhook.tf +++ b/modules/webhook/webhook.tf @@ -9,6 +9,7 @@ resource "aws_lambda_function" "webhook" { handler = "index.githubWebhook" runtime = var.lambda_runtime timeout = var.lambda_timeout + architectures = [var.lambda_architecture] environment { variables = { diff --git a/variables.tf b/variables.tf index 9148d0e323..e3d83c435b 100644 --- a/variables.tf +++ b/variables.tf @@ -641,3 +641,13 @@ variable "lambda_runtime" { type = string default = "nodejs14.x" } + +variable "lambda_architecture" { + description = "AWS Lambda architecture. Lambda functions using Graviton processors ('arm64') tend to have better price/performance than 'x86_64' functions. " + type = string + default = "x86_64" + validation { + condition = contains(["arm64", "x86_64"], var.lambda_architecture) + error_message = "`lambda_architecture` value is not valid, valid values are: `arm64` and `x86_64`." + } +} \ No newline at end of file
type = string
identifiers = list(string)
}))