From f038d636ce873ebe1f70620886b8dcb27ca25547 Mon Sep 17 00:00:00 2001 From: Moritz Zimmer Date: Fri, 1 Oct 2021 10:28:15 +0200 Subject: [PATCH] feat: added graviton support (#49) --- README.md | 7 ++++--- docs/part2.md | 7 ++++--- examples/container-image/versions.tf | 2 +- examples/deployment/container-image/versions.tf | 2 +- examples/deployment/s3/versions.tf | 2 +- examples/example-with-s3-event/versions.tf | 2 +- examples/simple/main.tf | 4 +++- examples/simple/versions.tf | 2 +- examples/with-cloudwatch-event-rules/versions.tf | 2 +- .../dynamodb-with-alias/versions.tf | 2 +- examples/with-event-source-mappings/kinesis/versions.tf | 2 +- examples/with-event-source-mappings/sqs/versions.tf | 2 +- examples/with-sns-subscriptions/versions.tf | 2 +- main.tf | 1 + modules/lambda/main.tf | 2 ++ modules/lambda/variables.tf | 6 ++++++ modules/lambda/versions.tf | 2 +- variables.tf | 8 +++++++- versions.tf | 2 +- 19 files changed, 39 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index fe6d53b..8002771 100644 --- a/README.md +++ b/README.md @@ -277,13 +277,13 @@ MINOR, and PATCH versions on each release to indicate any incompatibilities. | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.12.0 | -| [aws](#requirement\_aws) | >= 3.19 | +| [aws](#requirement\_aws) | >= 3.61 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | 3.56.0 | +| [aws](#provider\_aws) | >= 3.61 | ## Modules @@ -329,10 +329,11 @@ MINOR, and PATCH versions on each release to indicate any incompatibilities. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [architectures](#input\_architectures) | Instruction set architecture for your Lambda function. Valid values are ["x86\_64"] and ["arm64"]. Removing this attribute, function's architecture stay the same. | `list(string)` | `null` | no | | [cloudwatch\_event\_rules](#input\_cloudwatch\_event\_rules) | Creates EventBridge (CloudWatch Events) rules invoking your Lambda function. Required Lambda invocation permissions will be generated. | `map(any)` | `{}` | no | | [cloudwatch\_lambda\_insights\_enabled](#input\_cloudwatch\_lambda\_insights\_enabled) | Enable CloudWatch Lambda Insights for your Lambda function. | `bool` | `false` | no | | [cloudwatch\_lambda\_insights\_extension\_version](#input\_cloudwatch\_lambda\_insights\_extension\_version) | Version of the Lambda Insights extension for Lambda functions using `zip` deployment packages, see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Lambda-Insights-extension-versions.html. | `number` | `14` | no | -| [description](#input\_description) | Description of what your Lambda Function does. | `string` | `""` | no | +| [description](#input\_description) | Description of what your Lambda Function does. | `string` | `"Instruction set architecture for your Lambda function. Valid values are [\"x86_64\"] and [\"arm64\"]."` | no | | [environment](#input\_environment) | Environment (e.g. env variables) configuration for the Lambda function enable you to dynamically pass settings to your function code and libraries |
object({
variables = map(string)
})
| `null` | no | | [event](#input\_event) | (deprecated - use `cloudwatch_event_rules` [EventBridge/CloudWatch Events], `event_source_mappings` [DynamoDb, Kinesis, SQS] or `sns_subscriptions` [SNS] instead) Event source configuration which triggers the Lambda function. Supported events: cloudwatch-scheduled-event, dynamodb, kinesis, s3, sns, sqs | `map(string)` | `{}` | no | | [event\_source\_mappings](#input\_event\_source\_mappings) | Creates event source mappings to allow the Lambda function to get events from Kinesis, DynamoDB and SQS. The IAM role of this Lambda function will be enhanced with necessary minimum permissions to get those events. | `any` | `{}` | no | diff --git a/docs/part2.md b/docs/part2.md index 5c75349..4b0a580 100644 --- a/docs/part2.md +++ b/docs/part2.md @@ -3,13 +3,13 @@ | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.12.0 | -| [aws](#requirement\_aws) | >= 3.19 | +| [aws](#requirement\_aws) | >= 3.61 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | 3.56.0 | +| [aws](#provider\_aws) | >= 3.61 | ## Modules @@ -55,10 +55,11 @@ | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [architectures](#input\_architectures) | Instruction set architecture for your Lambda function. Valid values are ["x86\_64"] and ["arm64"]. Removing this attribute, function's architecture stay the same. | `list(string)` | `null` | no | | [cloudwatch\_event\_rules](#input\_cloudwatch\_event\_rules) | Creates EventBridge (CloudWatch Events) rules invoking your Lambda function. Required Lambda invocation permissions will be generated. | `map(any)` | `{}` | no | | [cloudwatch\_lambda\_insights\_enabled](#input\_cloudwatch\_lambda\_insights\_enabled) | Enable CloudWatch Lambda Insights for your Lambda function. | `bool` | `false` | no | | [cloudwatch\_lambda\_insights\_extension\_version](#input\_cloudwatch\_lambda\_insights\_extension\_version) | Version of the Lambda Insights extension for Lambda functions using `zip` deployment packages, see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Lambda-Insights-extension-versions.html. | `number` | `14` | no | -| [description](#input\_description) | Description of what your Lambda Function does. | `string` | `""` | no | +| [description](#input\_description) | Description of what your Lambda Function does. | `string` | `"Instruction set architecture for your Lambda function. Valid values are [\"x86_64\"] and [\"arm64\"]."` | no | | [environment](#input\_environment) | Environment (e.g. env variables) configuration for the Lambda function enable you to dynamically pass settings to your function code and libraries |
object({
variables = map(string)
})
| `null` | no | | [event](#input\_event) | (deprecated - use `cloudwatch_event_rules` [EventBridge/CloudWatch Events], `event_source_mappings` [DynamoDb, Kinesis, SQS] or `sns_subscriptions` [SNS] instead) Event source configuration which triggers the Lambda function. Supported events: cloudwatch-scheduled-event, dynamodb, kinesis, s3, sns, sqs | `map(string)` | `{}` | no | | [event\_source\_mappings](#input\_event\_source\_mappings) | Creates event source mappings to allow the Lambda function to get events from Kinesis, DynamoDB and SQS. The IAM role of this Lambda function will be enhanced with necessary minimum permissions to get those events. | `any` | `{}` | no | diff --git a/examples/container-image/versions.tf b/examples/container-image/versions.tf index d2e456b..e9a9b45 100644 --- a/examples/container-image/versions.tf +++ b/examples/container-image/versions.tf @@ -2,6 +2,6 @@ terraform { required_version = ">= 0.12" required_providers { - aws = ">= 3.19" + aws = ">= 3.61" } } diff --git a/examples/deployment/container-image/versions.tf b/examples/deployment/container-image/versions.tf index a43a719..469c4ac 100644 --- a/examples/deployment/container-image/versions.tf +++ b/examples/deployment/container-image/versions.tf @@ -2,6 +2,6 @@ terraform { required_version = ">= 0.12" required_providers { - aws = ">= 3.19" + aws = ">= 3.61" } } \ No newline at end of file diff --git a/examples/deployment/s3/versions.tf b/examples/deployment/s3/versions.tf index a43a719..469c4ac 100644 --- a/examples/deployment/s3/versions.tf +++ b/examples/deployment/s3/versions.tf @@ -2,6 +2,6 @@ terraform { required_version = ">= 0.12" required_providers { - aws = ">= 3.19" + aws = ">= 3.61" } } \ No newline at end of file diff --git a/examples/example-with-s3-event/versions.tf b/examples/example-with-s3-event/versions.tf index a43a719..469c4ac 100644 --- a/examples/example-with-s3-event/versions.tf +++ b/examples/example-with-s3-event/versions.tf @@ -2,6 +2,6 @@ terraform { required_version = ">= 0.12" required_providers { - aws = ">= 3.19" + aws = ">= 3.61" } } \ No newline at end of file diff --git a/examples/simple/main.tf b/examples/simple/main.tf index a379707..de6fa1d 100644 --- a/examples/simple/main.tf +++ b/examples/simple/main.tf @@ -3,7 +3,9 @@ module "source" { } module "lambda" { - source = "../../" + source = "../../" + + architectures = ["arm64"] description = "Example usage for an AWS Lambda without an event trigger." filename = module.source.output_path function_name = "example-without-event" diff --git a/examples/simple/versions.tf b/examples/simple/versions.tf index d2e456b..e9a9b45 100644 --- a/examples/simple/versions.tf +++ b/examples/simple/versions.tf @@ -2,6 +2,6 @@ terraform { required_version = ">= 0.12" required_providers { - aws = ">= 3.19" + aws = ">= 3.61" } } diff --git a/examples/with-cloudwatch-event-rules/versions.tf b/examples/with-cloudwatch-event-rules/versions.tf index d2e456b..e9a9b45 100644 --- a/examples/with-cloudwatch-event-rules/versions.tf +++ b/examples/with-cloudwatch-event-rules/versions.tf @@ -2,6 +2,6 @@ terraform { required_version = ">= 0.12" required_providers { - aws = ">= 3.19" + aws = ">= 3.61" } } diff --git a/examples/with-event-source-mappings/dynamodb-with-alias/versions.tf b/examples/with-event-source-mappings/dynamodb-with-alias/versions.tf index 90af41d..6ce3d31 100644 --- a/examples/with-event-source-mappings/dynamodb-with-alias/versions.tf +++ b/examples/with-event-source-mappings/dynamodb-with-alias/versions.tf @@ -2,6 +2,6 @@ terraform { required_version = ">= 0.12.0" required_providers { - aws = ">= 3.19" + aws = ">= 3.61" } } diff --git a/examples/with-event-source-mappings/kinesis/versions.tf b/examples/with-event-source-mappings/kinesis/versions.tf index 90af41d..6ce3d31 100644 --- a/examples/with-event-source-mappings/kinesis/versions.tf +++ b/examples/with-event-source-mappings/kinesis/versions.tf @@ -2,6 +2,6 @@ terraform { required_version = ">= 0.12.0" required_providers { - aws = ">= 3.19" + aws = ">= 3.61" } } diff --git a/examples/with-event-source-mappings/sqs/versions.tf b/examples/with-event-source-mappings/sqs/versions.tf index 90af41d..6ce3d31 100644 --- a/examples/with-event-source-mappings/sqs/versions.tf +++ b/examples/with-event-source-mappings/sqs/versions.tf @@ -2,6 +2,6 @@ terraform { required_version = ">= 0.12.0" required_providers { - aws = ">= 3.19" + aws = ">= 3.61" } } diff --git a/examples/with-sns-subscriptions/versions.tf b/examples/with-sns-subscriptions/versions.tf index d2e456b..e9a9b45 100644 --- a/examples/with-sns-subscriptions/versions.tf +++ b/examples/with-sns-subscriptions/versions.tf @@ -2,6 +2,6 @@ terraform { required_version = ">= 0.12" required_providers { - aws = ">= 3.19" + aws = ">= 3.61" } } diff --git a/main.tf b/main.tf index 7b79bed..768453f 100644 --- a/main.tf +++ b/main.tf @@ -5,6 +5,7 @@ data "aws_caller_identity" "current" {} module "lambda" { source = "./modules/lambda" + architectures = var.architectures cloudwatch_lambda_insights_enabled = var.cloudwatch_lambda_insights_enabled cloudwatch_lambda_insights_extension_version = var.cloudwatch_lambda_insights_extension_version description = var.description diff --git a/modules/lambda/main.tf b/modules/lambda/main.tf index 4b88768..d7311e7 100644 --- a/modules/lambda/main.tf +++ b/modules/lambda/main.tf @@ -6,6 +6,7 @@ locals { resource "aws_lambda_function" "lambda" { count = var.ignore_external_function_updates ? 0 : 1 + architectures = var.architectures description = var.description filename = var.filename function_name = var.function_name @@ -66,6 +67,7 @@ resource "aws_lambda_function" "lambda" { resource "aws_lambda_function" "lambda_external_lifecycle" { count = var.ignore_external_function_updates ? 1 : 0 + architectures = var.architectures description = var.description filename = var.filename function_name = var.function_name diff --git a/modules/lambda/variables.tf b/modules/lambda/variables.tf index ab33e07..e84a09f 100644 --- a/modules/lambda/variables.tf +++ b/modules/lambda/variables.tf @@ -12,6 +12,12 @@ variable "function_name" { # These parameters have reasonable defaults. # --------------------------------------------------------------------------------------------------------------------- +variable "architectures" { + default = null + description = "Instruction set architecture for your Lambda function. Valid values are [\"x86_64\"] and [\"arm64\"]. Removing this attribute, function's architecture stay the same." + type = list(string) +} + variable "cloudwatch_lambda_insights_enabled" { description = "Enable CloudWatch Lambda Insights for your Lambda function." default = false diff --git a/modules/lambda/versions.tf b/modules/lambda/versions.tf index 90af41d..6ce3d31 100644 --- a/modules/lambda/versions.tf +++ b/modules/lambda/versions.tf @@ -2,6 +2,6 @@ terraform { required_version = ">= 0.12.0" required_providers { - aws = ">= 3.19" + aws = ">= 3.61" } } diff --git a/variables.tf b/variables.tf index 48f80f5..65240b5 100644 --- a/variables.tf +++ b/variables.tf @@ -13,6 +13,12 @@ variable "function_name" { # These parameters have reasonable defaults. # --------------------------------------------------------------------------------------------------------------------- +variable "architectures" { + default = null + description = "Instruction set architecture for your Lambda function. Valid values are [\"x86_64\"] and [\"arm64\"]. Removing this attribute, function's architecture stay the same." + type = list(string) +} + variable "cloudwatch_event_rules" { description = "Creates EventBridge (CloudWatch Events) rules invoking your Lambda function. Required Lambda invocation permissions will be generated." default = {} @@ -33,7 +39,7 @@ variable "cloudwatch_lambda_insights_extension_version" { variable "description" { description = "Description of what your Lambda Function does." - default = "" + default = "Instruction set architecture for your Lambda function. Valid values are [\"x86_64\"] and [\"arm64\"]." type = string } diff --git a/versions.tf b/versions.tf index 90af41d..6ce3d31 100644 --- a/versions.tf +++ b/versions.tf @@ -2,6 +2,6 @@ terraform { required_version = ">= 0.12.0" required_providers { - aws = ">= 3.19" + aws = ">= 3.61" } }