Skip to content

Commit edac772

Browse files
author
João Taveira Araújo
authored
feat: select runtime / arch based off version (#66)
We provide newer builds that can run on `provided.al2` for different architectures. These builds are under a GOARCH directory (e.g. `arm64/latest`). This commit identifies what runtime, handler and architecture to use based off of the version string. Will defer switching the default for `lambda_version` to a future release.
1 parent ff93195 commit edac772

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

main.tf

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@ locals {
44
lambda_iam_role_name = regex(".*role/(?P<role_name>.*)$", local.lambda_iam_role_arn)["role_name"]
55
s3_bucket = var.s3_bucket != "" ? var.s3_bucket : lookup(var.s3_regional_buckets, data.aws_region.current.name, local.default_lambda_bucket)
66
s3_key = var.s3_key != "" ? var.s3_key : join("/", [var.s3_key_prefix, format("%s.zip", var.lambda_version)])
7+
8+
goarch = lookup(
9+
{
10+
"amd64" : {
11+
architectures = ["x86_64"]
12+
handler = "bootstrap"
13+
runtime = "provided.al2"
14+
}
15+
"arm64" : {
16+
architectures = ["arm64"]
17+
handler = "bootstrap"
18+
runtime = "provided.al2"
19+
}
20+
},
21+
split("/", var.lambda_version)[0],
22+
{
23+
architectures = null
24+
handler = "main"
25+
runtime = "go1.x"
26+
},
27+
)
728
}
829

930
data "aws_region" "current" {}
@@ -15,11 +36,12 @@ resource "aws_lambda_function" "this" {
1536
s3_object_version = var.s3_object_version
1637
role = local.lambda_iam_role_arn
1738

18-
handler = "main"
19-
runtime = "go1.x"
20-
description = var.description
21-
kms_key_arn = var.kms_key_arn
22-
tags = var.tags
39+
architectures = local.goarch.architectures
40+
handler = local.goarch.handler
41+
runtime = local.goarch.runtime
42+
description = var.description
43+
kms_key_arn = var.kms_key_arn
44+
tags = var.tags
2345

2446
memory_size = var.memory_size
2547
reserved_concurrent_executions = var.reserved_concurrent_executions < 0 ? null : var.reserved_concurrent_executions

0 commit comments

Comments
 (0)