Skip to content

Commit 3873c10

Browse files
authored
feat: Add support for AWS Graviton2 powered functions (#206)
1 parent 361ceb1 commit 3873c10

File tree

8 files changed

+30
-11
lines changed

8 files changed

+30
-11
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ Q4: What does this error mean - `"We currently do not support adding policies fo
590590
| Name | Version |
591591
|------|---------|
592592
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.31 |
593-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.43 |
593+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.61 |
594594
| <a name="requirement_external"></a> [external](#requirement\_external) | >= 1 |
595595
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 1 |
596596
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2 |
@@ -599,7 +599,7 @@ Q4: What does this error mean - `"We currently do not support adding policies fo
599599

600600
| Name | Version |
601601
|------|---------|
602-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.43 |
602+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.61 |
603603
| <a name="provider_external"></a> [external](#provider\_external) | >= 1 |
604604
| <a name="provider_local"></a> [local](#provider\_local) | >= 1 |
605605
| <a name="provider_null"></a> [null](#provider\_null) | >= 2 |
@@ -659,6 +659,7 @@ No modules.
659659
| Name | Description | Type | Default | Required |
660660
|------|-------------|------|---------|:--------:|
661661
| <a name="input_allowed_triggers"></a> [allowed\_triggers](#input\_allowed\_triggers) | Map of allowed triggers to create Lambda permissions | `map(any)` | `{}` | no |
662+
| <a name="input_architectures"></a> [architectures](#input\_architectures) | Instruction set architecture for your Lambda function. Valid values are ["x86\_64"] and ["arm64"]. | `list(string)` | `null` | no |
662663
| <a name="input_artifacts_dir"></a> [artifacts\_dir](#input\_artifacts\_dir) | Directory name where artifacts should be stored | `string` | `"builds"` | no |
663664
| <a name="input_assume_role_policy_statements"></a> [assume\_role\_policy\_statements](#input\_assume\_role\_policy\_statements) | Map of dynamic policy statements for assuming Lambda Function role (trust relationship) | `any` | `{}` | no |
664665
| <a name="input_attach_async_event_policy"></a> [attach\_async\_event\_policy](#input\_attach\_async\_event\_policy) | Controls whether async event policy should be added to IAM role for Lambda Function | `bool` | `false` | no |
@@ -675,6 +676,7 @@ No modules.
675676
| <a name="input_cloudwatch_logs_kms_key_id"></a> [cloudwatch\_logs\_kms\_key\_id](#input\_cloudwatch\_logs\_kms\_key\_id) | The ARN of the KMS Key to use when encrypting log data. | `string` | `null` | no |
676677
| <a name="input_cloudwatch_logs_retention_in_days"></a> [cloudwatch\_logs\_retention\_in\_days](#input\_cloudwatch\_logs\_retention\_in\_days) | Specifies the number of days you want to retain log events in the specified log group. Possible values are: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653. | `number` | `null` | no |
677678
| <a name="input_cloudwatch_logs_tags"></a> [cloudwatch\_logs\_tags](#input\_cloudwatch\_logs\_tags) | A map of tags to assign to the resource. | `map(string)` | `{}` | no |
679+
| <a name="input_compatible_architectures"></a> [compatible\_architectures](#input\_compatible\_architectures) | A list of Architectures Lambda layer is compatible with. Currently x86\_64 and arm64 can be specified. | `list(string)` | `null` | no |
678680
| <a name="input_compatible_runtimes"></a> [compatible\_runtimes](#input\_compatible\_runtimes) | A list of Runtimes this layer is compatible with. Up to 5 runtimes can be specified. | `list(string)` | `[]` | no |
679681
| <a name="input_create"></a> [create](#input\_create) | Controls whether resources should be created | `bool` | `true` | no |
680682
| <a name="input_create_async_event_config"></a> [create\_async\_event\_config](#input\_create\_async\_event\_config) | Controls whether async event configuration for Lambda Function/Alias should be created | `bool` | `false` | no |

examples/async/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ Note that this example may create resources which cost money. Run `terraform des
2020
| Name | Version |
2121
|------|---------|
2222
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.31 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.19 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.61 |
2424
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2 |
2525

2626
## Providers
2727

2828
| Name | Version |
2929
|------|---------|
30-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.19 |
30+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.61 |
3131
| <a name="provider_random"></a> [random](#provider\_random) | >= 2 |
3232

3333
## Modules

examples/async/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module "lambda_function" {
1919
function_name = "${random_pet.this.id}-lambda-async"
2020
handler = "index.lambda_handler"
2121
runtime = "python3.8"
22+
architectures = ["arm64"]
2223

2324
source_path = "${path.module}/../fixtures/python3.8-app1"
2425

examples/async/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_version = ">= 0.12.31"
33

44
required_providers {
5-
aws = ">= 3.19"
5+
aws = ">= 3.61"
66
random = ">= 2"
77
}
88
}

examples/complete/main.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module "lambda_function" {
2121
description = "My awesome lambda function"
2222
handler = "index.lambda_handler"
2323
runtime = "python3.8"
24+
architectures = ["x86_64"]
2425
publish = true
2526

2627
source_path = "${path.module}/../fixtures/python3.8-app1"
@@ -183,9 +184,10 @@ module "lambda_layer_local" {
183184

184185
create_layer = true
185186

186-
layer_name = "${random_pet.this.id}-layer-local"
187-
description = "My amazing lambda layer (deployed from local)"
188-
compatible_runtimes = ["python3.8"]
187+
layer_name = "${random_pet.this.id}-layer-local"
188+
description = "My amazing lambda layer (deployed from local)"
189+
compatible_runtimes = ["python3.8"]
190+
compatible_architectures = ["arm64"]
189191

190192
source_path = "${path.module}/../fixtures/python3.8-app1"
191193
}

main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ resource "aws_lambda_function" "this" {
3232
kms_key_arn = var.kms_key_arn
3333
image_uri = var.image_uri
3434
package_type = var.package_type
35+
architectures = var.architectures
3536

3637
filename = local.filename
3738
source_code_hash = var.ignore_source_code_hash ? null : (local.filename == null ? false : fileexists(local.filename)) && !local.was_missing ? filebase64sha256(local.filename) : null
@@ -102,7 +103,8 @@ resource "aws_lambda_layer_version" "this" {
102103
description = var.description
103104
license_info = var.license_info
104105

105-
compatible_runtimes = length(var.compatible_runtimes) > 0 ? var.compatible_runtimes : [var.runtime]
106+
compatible_runtimes = length(var.compatible_runtimes) > 0 ? var.compatible_runtimes : [var.runtime]
107+
compatible_architectures = var.compatible_architectures
106108

107109
filename = local.filename
108110
source_code_hash = var.ignore_source_code_hash ? null : (local.filename == null ? false : fileexists(local.filename)) && !local.was_missing ? filebase64sha256(local.filename) : null

variables.tf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ variable "layers" {
7979
default = null
8080
}
8181

82+
variable "architectures" {
83+
description = "Instruction set architecture for your Lambda function. Valid values are [\"x86_64\"] and [\"arm64\"]."
84+
type = list(string)
85+
default = null
86+
}
87+
8288
variable "kms_key_arn" {
8389
description = "The ARN of KMS key to use by your Lambda Function"
8490
type = string
@@ -203,6 +209,12 @@ variable "compatible_runtimes" {
203209
default = []
204210
}
205211

212+
variable "compatible_architectures" {
213+
description = "A list of Architectures Lambda layer is compatible with. Currently x86_64 and arm64 can be specified."
214+
type = list(string)
215+
default = null
216+
}
217+
206218
############################
207219
# Lambda Async Event Config
208220
############################
@@ -605,4 +617,4 @@ variable "recreate_missing_package" {
605617
description = "Whether to recreate missing Lambda package if it is missing locally or not"
606618
type = bool
607619
default = true
608-
}
620+
}

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_version = ">= 0.12.31"
33

44
required_providers {
5-
aws = ">= 3.43"
5+
aws = ">= 3.61"
66
external = ">= 1"
77
local = ">= 1"
88
null = ">= 2"

0 commit comments

Comments
 (0)