Skip to content

Commit

Permalink
feat: Support arm64 lambda functions (#2121)
Browse files Browse the repository at this point in the history
* feat: Support arm64 lambda functions

* chore: Default to existing behavior, update readme

* chore: terraform fmt, add validation to lambda architecture, update description

* feat: Add arm64 support to pool lambda

* fix: Wrong variable name in the lambda function

* fix: var.config.lambda_architecture instead of var.lambda_architecture in lambda pool

* fix: It should have been lambda.architecture not lambda_architecture.

* chore: Change default to x86_64

Co-authored-by: Niek Palm <[email protected]>

* chore: Change default to x86_64

Co-authored-by: Niek Palm <[email protected]>

* chore: Change default to x86_64

Co-authored-by: Niek Palm <[email protected]>

* chore: Change default to x86_64

Co-authored-by: Niek Palm <[email protected]>

Co-authored-by: Niek Palm <[email protected]>
  • Loading branch information
dylanmtaylor and npalm authored Jun 10, 2022
1 parent 56b2c3a commit 9e2a7b6
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ In case the setup does not work as intended follow the trace of events:
| <a name="input_kms_key_arn"></a> [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 |
| <a name="input_lambda_principals"></a> [lambda\_principals](#input\_lambda\_principals) | (Optional) add extra principals to the role created for execution of the lambda, e.g. for local testing. | <pre>list(object({<br> type = string<br> identifiers = list(string)<br> }))</pre> | `[]` | no |
| <a name="input_lambda_runtime"></a> [lambda\_runtime](#input\_lambda\_runtime) | AWS Lambda runtime. | `string` | `"nodejs14.x"` | no |
| <a name="input_lambda_architecture"></a> [lambda\_architecture](#input\_lambda\_architecture) | AWS Lambda architecture. | `string` | `"x86_64"` | no |
| <a name="input_lambda_s3_bucket"></a> [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 |
| <a name="input_lambda_security_group_ids"></a> [lambda\_security\_group\_ids](#input\_lambda\_security\_group\_ids) | List of security group IDs associated with the Lambda function. | `list(string)` | `[]` | no |
| <a name="input_lambda_subnet_ids"></a> [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 |
Expand Down
3 changes: 3 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions modules/runner-binaries-syncer/runner-binaries-syncer.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
10 changes: 10 additions & 0 deletions modules/runner-binaries-syncer/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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`."
}
}
1 change: 1 addition & 0 deletions modules/runners/pool.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions modules/runners/pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions modules/runners/pool/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions modules/runners/scale-down.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions modules/runners/scale-up.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
10 changes: 10 additions & 0 deletions modules/runners/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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`."
}
}
10 changes: 10 additions & 0 deletions modules/webhook/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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`."
}
}
1 change: 1 addition & 0 deletions modules/webhook/webhook.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
10 changes: 10 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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`."
}
}

0 comments on commit 9e2a7b6

Please sign in to comment.