From f191baea053e126fc6b83a2ea4d6988c4f47ebde Mon Sep 17 00:00:00 2001 From: liortct <38353773+liortct@users.noreply.github.com> Date: Sat, 26 Mar 2022 23:26:26 +0300 Subject: [PATCH 1/3] feat: Added support for ephemeral storage (requires AWS provider version 4.8.0) (#291) Co-authored-by: Anton Babenko --- README.md | 11 ++++++----- examples/complete/main.tf | 13 +++++++------ examples/complete/versions.tf | 2 +- main.tf | 12 ++++++++---- variables.tf | 6 ++++++ versions.tf | 2 +- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 005c2a38..64c74e36 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ resource "aws_s3_bucket" "builds" { acl = "private" } -resource "aws_s3_bucket_object" "my_function" { +resource "aws_s3_object" "my_function" { bucket = aws_s3_bucket.builds.id key = "${filemd5(local.my_function_source)}.zip" source = local.my_function_source @@ -165,7 +165,7 @@ module "lambda_function_existing_package_s3" { create_package = false s3_existing_package = { bucket = aws_s3_bucket.builds.id - key = aws_s3_bucket_object.my_function.id + key = aws_s3_object.my_function.id } } ``` @@ -602,7 +602,7 @@ Q4: What does this error mean - `"We currently do not support adding policies fo | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.69 | +| [aws](#requirement\_aws) | >= 4.8.0 | | [external](#requirement\_external) | >= 1.0 | | [local](#requirement\_local) | >= 1.0 | | [null](#requirement\_null) | >= 2.0 | @@ -611,7 +611,7 @@ Q4: What does this error mean - `"We currently do not support adding policies fo | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.69 | +| [aws](#provider\_aws) | >= 4.8.0 | | [external](#provider\_external) | >= 1.0 | | [local](#provider\_local) | >= 1.0 | | [null](#provider\_null) | >= 2.0 | @@ -651,7 +651,7 @@ No modules. | [aws_lambda_permission.current_version_triggers](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource | | [aws_lambda_permission.unqualified_alias_triggers](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource | | [aws_lambda_provisioned_concurrency_config.current_version](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_provisioned_concurrency_config) | resource | -| [aws_s3_bucket_object.lambda_package](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object) | resource | +| [aws_s3_object.lambda_package](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_object) | resource | | [local_file.archive_plan](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource | | [null_resource.archive](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | | [aws_arn.log_group_arn](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | data source | @@ -710,6 +710,7 @@ No modules. | [docker\_pip\_cache](#input\_docker\_pip\_cache) | Whether to mount a shared pip cache folder into docker environment or not | `any` | `null` | no | | [docker\_with\_ssh\_agent](#input\_docker\_with\_ssh\_agent) | Whether to pass SSH\_AUTH\_SOCK into docker environment or not | `bool` | `false` | no | | [environment\_variables](#input\_environment\_variables) | A map that defines environment variables for the Lambda Function. | `map(string)` | `{}` | no | +| [ephemeral\_storage\_size](#input\_ephemeral\_storage\_size) | Amount of ephemeral storage size (`/tmp`) in MB your Lambda Function can use at runtime. Valid value between 512 MB to 10,240 MB (10 GB). | `number` | `512` | no | | [event\_source\_mapping](#input\_event\_source\_mapping) | Map of event source mapping | `any` | `{}` | no | | [file\_system\_arn](#input\_file\_system\_arn) | The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system. | `string` | `null` | no | | [file\_system\_local\_mount\_path](#input\_file\_system\_local\_mount\_path) | The path where the function can access the file system, starting with /mnt/. | `string` | `null` | no | diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 4c4a0208..56bc0383 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -17,12 +17,13 @@ provider "aws" { module "lambda_function" { source = "../../" - function_name = "${random_pet.this.id}-lambda1" - description = "My awesome lambda function" - handler = "index.lambda_handler" - runtime = "python3.8" - architectures = ["x86_64"] - publish = true + function_name = "${random_pet.this.id}-lambda1" + description = "My awesome lambda function" + handler = "index.lambda_handler" + runtime = "python3.8" + ephemeral_storage_size = 10240 + architectures = ["x86_64"] + publish = true source_path = "${path.module}/../fixtures/python3.8-app1" diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index a32909ec..9e58d511 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -2,7 +2,7 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 2.67" + aws = ">= 4.8.0" random = ">= 2" } } diff --git a/main.tf b/main.tf index 24f81116..5296554c 100644 --- a/main.tf +++ b/main.tf @@ -15,7 +15,7 @@ locals { # s3_* - to get package from S3 s3_bucket = var.s3_existing_package != null ? lookup(var.s3_existing_package, "bucket", null) : (var.store_on_s3 ? var.s3_bucket : null) s3_key = var.s3_existing_package != null ? lookup(var.s3_existing_package, "key", null) : (var.store_on_s3 ? var.s3_prefix != null ? format("%s%s", var.s3_prefix, replace(local.archive_filename_string, "/^.*//", "")) : replace(local.archive_filename_string, "/^\\.//", "") : null) - s3_object_version = var.s3_existing_package != null ? lookup(var.s3_existing_package, "version_id", null) : (var.store_on_s3 ? try(aws_s3_bucket_object.lambda_package[0].version_id, null) : null) + s3_object_version = var.s3_existing_package != null ? lookup(var.s3_existing_package, "version_id", null) : (var.store_on_s3 ? try(aws_s3_object.lambda_package[0].version_id, null) : null) } @@ -37,6 +37,10 @@ resource "aws_lambda_function" "this" { package_type = var.package_type architectures = var.architectures + ephemeral_storage { + size = var.ephemeral_storage_size + } + filename = local.filename source_code_hash = var.ignore_source_code_hash ? null : (local.filename == null ? false : fileexists(local.filename)) && !local.was_missing ? filebase64sha256(local.filename) : null @@ -96,7 +100,7 @@ resource "aws_lambda_function" "this" { # When a lambda function is invoked, AWS creates the log group automatically if it doesn't exist yet. # Without the dependency, this can result in a race condition if the lambda function is invoked before # Terraform can create the log group. - depends_on = [null_resource.archive, aws_s3_bucket_object.lambda_package, aws_cloudwatch_log_group.lambda] + depends_on = [null_resource.archive, aws_s3_object.lambda_package, aws_cloudwatch_log_group.lambda] } resource "aws_lambda_layer_version" "this" { @@ -117,10 +121,10 @@ resource "aws_lambda_layer_version" "this" { s3_key = local.s3_key s3_object_version = local.s3_object_version - depends_on = [null_resource.archive, aws_s3_bucket_object.lambda_package] + depends_on = [null_resource.archive, aws_s3_object.lambda_package] } -resource "aws_s3_bucket_object" "lambda_package" { +resource "aws_s3_object" "lambda_package" { count = local.create && var.store_on_s3 && var.create_package ? 1 : 0 bucket = var.s3_bucket diff --git a/variables.tf b/variables.tf index 24243bfa..b1751877 100644 --- a/variables.tf +++ b/variables.tf @@ -103,6 +103,12 @@ variable "memory_size" { default = 128 } +variable "ephemeral_storage_size" { + description = "Amount of ephemeral storage (/tmp) in MB your Lambda Function can use at runtime. Valid value between 512 MB to 10,240 MB (10 GB)." + type = number + default = 512 +} + variable "publish" { description = "Whether to publish creation/change as new Lambda Function Version." type = bool diff --git a/versions.tf b/versions.tf index 3727a394..e54af37b 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3.69" + version = ">= 4.8.0" } external = { source = "hashicorp/external" From d4b55a8bb142a7124f4cd910d68a631d9658260e Mon Sep 17 00:00:00 2001 From: Anton Babenko Date: Mon, 28 Mar 2022 10:19:30 +0200 Subject: [PATCH 2/3] feat!: Updated AWS provider to version 4.8 (#296) This is the correction after #291 BREAKING CHANGES: - Yes --- README.md | 6 +-- examples/alias/README.md | 4 +- examples/alias/versions.tf | 10 ++++- examples/async/README.md | 4 +- examples/async/versions.tf | 10 ++++- examples/build-package/README.md | 4 +- examples/build-package/versions.tf | 10 ++++- examples/complete/README.md | 8 ++-- examples/complete/versions.tf | 10 ++++- examples/container-image/README.md | 4 +- examples/container-image/versions.tf | 10 ++++- examples/deploy/README.md | 4 +- examples/deploy/versions.tf | 10 ++++- examples/multiple-regions/README.md | 4 +- examples/multiple-regions/versions.tf | 10 ++++- examples/simple/README.md | 4 +- examples/simple/versions.tf | 10 ++++- examples/triggers/README.md | 4 +- examples/triggers/versions.tf | 10 ++++- examples/with-efs/README.md | 4 +- examples/with-efs/versions.tf | 10 ++++- examples/with-vpc/README.md | 4 +- examples/with-vpc/versions.tf | 10 ++++- iam.tf | 32 +++++++------- main.tf | 62 +++++++++++++-------------- modules/alias/main.tf | 24 +++++------ modules/alias/versions.tf | 5 ++- modules/deploy/README.md | 8 ++-- modules/deploy/versions.tf | 15 +++++-- versions.tf | 2 +- 30 files changed, 195 insertions(+), 117 deletions(-) diff --git a/README.md b/README.md index 64c74e36..86d97204 100644 --- a/README.md +++ b/README.md @@ -602,7 +602,7 @@ Q4: What does this error mean - `"We currently do not support adding policies fo | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 4.8.0 | +| [aws](#requirement\_aws) | >= 4.8 | | [external](#requirement\_external) | >= 1.0 | | [local](#requirement\_local) | >= 1.0 | | [null](#requirement\_null) | >= 2.0 | @@ -611,7 +611,7 @@ Q4: What does this error mean - `"We currently do not support adding policies fo | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 4.8.0 | +| [aws](#provider\_aws) | >= 4.8 | | [external](#provider\_external) | >= 1.0 | | [local](#provider\_local) | >= 1.0 | | [null](#provider\_null) | >= 2.0 | @@ -710,7 +710,7 @@ No modules. | [docker\_pip\_cache](#input\_docker\_pip\_cache) | Whether to mount a shared pip cache folder into docker environment or not | `any` | `null` | no | | [docker\_with\_ssh\_agent](#input\_docker\_with\_ssh\_agent) | Whether to pass SSH\_AUTH\_SOCK into docker environment or not | `bool` | `false` | no | | [environment\_variables](#input\_environment\_variables) | A map that defines environment variables for the Lambda Function. | `map(string)` | `{}` | no | -| [ephemeral\_storage\_size](#input\_ephemeral\_storage\_size) | Amount of ephemeral storage size (`/tmp`) in MB your Lambda Function can use at runtime. Valid value between 512 MB to 10,240 MB (10 GB). | `number` | `512` | no | +| [ephemeral\_storage\_size](#input\_ephemeral\_storage\_size) | Amount of ephemeral storage (/tmp) in MB your Lambda Function can use at runtime. Valid value between 512 MB to 10,240 MB (10 GB). | `number` | `512` | no | | [event\_source\_mapping](#input\_event\_source\_mapping) | Map of event source mapping | `any` | `{}` | no | | [file\_system\_arn](#input\_file\_system\_arn) | The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system. | `string` | `null` | no | | [file\_system\_local\_mount\_path](#input\_file\_system\_local\_mount\_path) | The path where the function can access the file system, starting with /mnt/. | `string` | `null` | no | diff --git a/examples/alias/README.md b/examples/alias/README.md index 950588b7..c57e10b8 100644 --- a/examples/alias/README.md +++ b/examples/alias/README.md @@ -21,13 +21,13 @@ Note that this example may create resources which cost money. Run `terraform des |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | | [aws](#requirement\_aws) | >= 3.19 | -| [random](#requirement\_random) | >= 2 | +| [random](#requirement\_random) | >= 2.0 | ## Providers | Name | Version | |------|---------| -| [random](#provider\_random) | >= 2 | +| [random](#provider\_random) | >= 2.0 | ## Modules diff --git a/examples/alias/versions.tf b/examples/alias/versions.tf index d977ca64..6f0e3af3 100644 --- a/examples/alias/versions.tf +++ b/examples/alias/versions.tf @@ -2,7 +2,13 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.19" - random = ">= 2" + aws = { + source = "hashicorp/aws" + version = ">= 3.19" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } } } diff --git a/examples/async/README.md b/examples/async/README.md index 024f1237..326d1f7b 100644 --- a/examples/async/README.md +++ b/examples/async/README.md @@ -21,14 +21,14 @@ Note that this example may create resources which cost money. Run `terraform des |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | | [aws](#requirement\_aws) | >= 3.61 | -| [random](#requirement\_random) | >= 2 | +| [random](#requirement\_random) | >= 2.0 | ## Providers | Name | Version | |------|---------| | [aws](#provider\_aws) | >= 3.61 | -| [random](#provider\_random) | >= 2 | +| [random](#provider\_random) | >= 2.0 | ## Modules diff --git a/examples/async/versions.tf b/examples/async/versions.tf index 16aefdd0..2a88692a 100644 --- a/examples/async/versions.tf +++ b/examples/async/versions.tf @@ -2,7 +2,13 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.61" - random = ">= 2" + aws = { + source = "hashicorp/aws" + version = ">= 3.61" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } } } diff --git a/examples/build-package/README.md b/examples/build-package/README.md index 0d1f4a4f..739e8b0a 100644 --- a/examples/build-package/README.md +++ b/examples/build-package/README.md @@ -21,13 +21,13 @@ Note that this example may create resources which cost money. Run `terraform des |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | | [aws](#requirement\_aws) | >= 3.19 | -| [random](#requirement\_random) | >= 2 | +| [random](#requirement\_random) | >= 2.0 | ## Providers | Name | Version | |------|---------| -| [random](#provider\_random) | >= 2 | +| [random](#provider\_random) | >= 2.0 | ## Modules diff --git a/examples/build-package/versions.tf b/examples/build-package/versions.tf index d977ca64..6f0e3af3 100644 --- a/examples/build-package/versions.tf +++ b/examples/build-package/versions.tf @@ -2,7 +2,13 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.19" - random = ">= 2" + aws = { + source = "hashicorp/aws" + version = ">= 3.19" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } } } diff --git a/examples/complete/README.md b/examples/complete/README.md index 4c4f92f1..d4dc6595 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -21,15 +21,15 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 2.67 | -| [random](#requirement\_random) | >= 2 | +| [aws](#requirement\_aws) | >= 4.8 | +| [random](#requirement\_random) | >= 2.0 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 2.67 | -| [random](#provider\_random) | >= 2 | +| [aws](#provider\_aws) | >= 4.8 | +| [random](#provider\_random) | >= 2.0 | ## Modules diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index 9e58d511..b19bca77 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -2,7 +2,13 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 4.8.0" - random = ">= 2" + aws = { + source = "hashicorp/aws" + version = ">= 4.8" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } } } diff --git a/examples/container-image/README.md b/examples/container-image/README.md index c44653c9..83ba91b5 100644 --- a/examples/container-image/README.md +++ b/examples/container-image/README.md @@ -21,13 +21,13 @@ Note that this example may create resources which cost money. Run `terraform des |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | | [aws](#requirement\_aws) | >= 3.19 | -| [random](#requirement\_random) | >= 2 | +| [random](#requirement\_random) | >= 2.0 | ## Providers | Name | Version | |------|---------| -| [random](#provider\_random) | >= 2 | +| [random](#provider\_random) | >= 2.0 | ## Modules diff --git a/examples/container-image/versions.tf b/examples/container-image/versions.tf index d977ca64..6f0e3af3 100644 --- a/examples/container-image/versions.tf +++ b/examples/container-image/versions.tf @@ -2,7 +2,13 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.19" - random = ">= 2" + aws = { + source = "hashicorp/aws" + version = ">= 3.19" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } } } diff --git a/examples/deploy/README.md b/examples/deploy/README.md index ada8f65a..5b0846f0 100644 --- a/examples/deploy/README.md +++ b/examples/deploy/README.md @@ -21,14 +21,14 @@ Note that this example may create resources which cost money. Run `terraform des |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | | [aws](#requirement\_aws) | >= 3.19 | -| [random](#requirement\_random) | >= 2 | +| [random](#requirement\_random) | >= 2.0 | ## Providers | Name | Version | |------|---------| | [aws](#provider\_aws) | >= 3.19 | -| [random](#provider\_random) | >= 2 | +| [random](#provider\_random) | >= 2.0 | ## Modules diff --git a/examples/deploy/versions.tf b/examples/deploy/versions.tf index d977ca64..6f0e3af3 100644 --- a/examples/deploy/versions.tf +++ b/examples/deploy/versions.tf @@ -2,7 +2,13 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.19" - random = ">= 2" + aws = { + source = "hashicorp/aws" + version = ">= 3.19" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } } } diff --git a/examples/multiple-regions/README.md b/examples/multiple-regions/README.md index 39ca75f6..3673cc1a 100644 --- a/examples/multiple-regions/README.md +++ b/examples/multiple-regions/README.md @@ -22,7 +22,7 @@ Note that this example may create resources which cost money. Run `terraform des |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | | [aws](#requirement\_aws) | >= 3.19 | -| [random](#requirement\_random) | >= 2 | +| [random](#requirement\_random) | >= 2.0 | ## Providers @@ -30,7 +30,7 @@ Note that this example may create resources which cost money. Run `terraform des |------|---------| | [aws](#provider\_aws) | >= 3.19 | | [aws.us-east-1](#provider\_aws.us-east-1) | >= 3.19 | -| [random](#provider\_random) | >= 2 | +| [random](#provider\_random) | >= 2.0 | ## Modules diff --git a/examples/multiple-regions/versions.tf b/examples/multiple-regions/versions.tf index d977ca64..6f0e3af3 100644 --- a/examples/multiple-regions/versions.tf +++ b/examples/multiple-regions/versions.tf @@ -2,7 +2,13 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.19" - random = ">= 2" + aws = { + source = "hashicorp/aws" + version = ">= 3.19" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } } } diff --git a/examples/simple/README.md b/examples/simple/README.md index fafada37..6fe52aa2 100644 --- a/examples/simple/README.md +++ b/examples/simple/README.md @@ -21,13 +21,13 @@ Note that this example may create resources which cost money. Run `terraform des |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | | [aws](#requirement\_aws) | >= 3.19 | -| [random](#requirement\_random) | >= 2 | +| [random](#requirement\_random) | >= 2.0 | ## Providers | Name | Version | |------|---------| -| [random](#provider\_random) | >= 2 | +| [random](#provider\_random) | >= 2.0 | ## Modules diff --git a/examples/simple/versions.tf b/examples/simple/versions.tf index d977ca64..6f0e3af3 100644 --- a/examples/simple/versions.tf +++ b/examples/simple/versions.tf @@ -2,7 +2,13 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.19" - random = ">= 2" + aws = { + source = "hashicorp/aws" + version = ">= 3.19" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } } } diff --git a/examples/triggers/README.md b/examples/triggers/README.md index 8fc7adb8..973963f5 100644 --- a/examples/triggers/README.md +++ b/examples/triggers/README.md @@ -22,14 +22,14 @@ Note that this example may create resources which cost money. Run `terraform des |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | | [aws](#requirement\_aws) | >= 2.67 | -| [random](#requirement\_random) | >= 2 | +| [random](#requirement\_random) | >= 2.0 | ## Providers | Name | Version | |------|---------| | [aws](#provider\_aws) | >= 2.67 | -| [random](#provider\_random) | >= 2 | +| [random](#provider\_random) | >= 2.0 | ## Modules diff --git a/examples/triggers/versions.tf b/examples/triggers/versions.tf index a32909ec..13f523bb 100644 --- a/examples/triggers/versions.tf +++ b/examples/triggers/versions.tf @@ -2,7 +2,13 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 2.67" - random = ">= 2" + aws = { + source = "hashicorp/aws" + version = ">= 2.67" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } } } diff --git a/examples/with-efs/README.md b/examples/with-efs/README.md index 52135ffb..a923c6b7 100644 --- a/examples/with-efs/README.md +++ b/examples/with-efs/README.md @@ -22,14 +22,14 @@ Note that this example may create resources which cost money. Run `terraform des |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | | [aws](#requirement\_aws) | >= 3.19 | -| [random](#requirement\_random) | >= 2 | +| [random](#requirement\_random) | >= 2.0 | ## Providers | Name | Version | |------|---------| | [aws](#provider\_aws) | >= 3.19 | -| [random](#provider\_random) | >= 2 | +| [random](#provider\_random) | >= 2.0 | ## Modules diff --git a/examples/with-efs/versions.tf b/examples/with-efs/versions.tf index d977ca64..6f0e3af3 100644 --- a/examples/with-efs/versions.tf +++ b/examples/with-efs/versions.tf @@ -2,7 +2,13 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.19" - random = ">= 2" + aws = { + source = "hashicorp/aws" + version = ">= 3.19" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } } } diff --git a/examples/with-vpc/README.md b/examples/with-vpc/README.md index 5c632d07..2f7a7be8 100644 --- a/examples/with-vpc/README.md +++ b/examples/with-vpc/README.md @@ -23,13 +23,13 @@ Note that this example may create resources which cost money. Run `terraform des |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | | [aws](#requirement\_aws) | >= 3.19 | -| [random](#requirement\_random) | >= 2 | +| [random](#requirement\_random) | >= 2.0 | ## Providers | Name | Version | |------|---------| -| [random](#provider\_random) | >= 2 | +| [random](#provider\_random) | >= 2.0 | ## Modules diff --git a/examples/with-vpc/versions.tf b/examples/with-vpc/versions.tf index d977ca64..6f0e3af3 100644 --- a/examples/with-vpc/versions.tf +++ b/examples/with-vpc/versions.tf @@ -2,7 +2,13 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.19" - random = ">= 2" + aws = { + source = "hashicorp/aws" + version = ">= 3.19" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } } } diff --git a/iam.tf b/iam.tf index 6102fc66..93d444a2 100644 --- a/iam.tf +++ b/iam.tf @@ -57,13 +57,13 @@ data "aws_iam_policy_document" "assume_role" { for_each = var.assume_role_policy_statements content { - sid = lookup(statement.value, "sid", replace(statement.key, "/[^0-9A-Za-z]*/", "")) - effect = lookup(statement.value, "effect", null) - actions = lookup(statement.value, "actions", null) - not_actions = lookup(statement.value, "not_actions", null) + sid = try(statement.value.sid, replace(statement.key, "/[^0-9A-Za-z]*/", "")) + effect = try(statement.value.effect, null) + actions = try(statement.value.actions, null) + not_actions = try(statement.value.not_actions, null) dynamic "principals" { - for_each = lookup(statement.value, "principals", []) + for_each = try(statement.value.principals, []) content { type = principals.value.type identifiers = principals.value.identifiers @@ -71,7 +71,7 @@ data "aws_iam_policy_document" "assume_role" { } dynamic "not_principals" { - for_each = lookup(statement.value, "not_principals", []) + for_each = try(statement.value.not_principals, []) content { type = not_principals.value.type identifiers = not_principals.value.identifiers @@ -79,7 +79,7 @@ data "aws_iam_policy_document" "assume_role" { } dynamic "condition" { - for_each = lookup(statement.value, "condition", []) + for_each = try(statement.value.condition, []) content { test = condition.value.test variable = condition.value.variable @@ -346,15 +346,15 @@ data "aws_iam_policy_document" "additional_inline" { for_each = var.policy_statements content { - sid = lookup(statement.value, "sid", replace(statement.key, "/[^0-9A-Za-z]*/", "")) - effect = lookup(statement.value, "effect", null) - actions = lookup(statement.value, "actions", null) - not_actions = lookup(statement.value, "not_actions", null) - resources = lookup(statement.value, "resources", null) - not_resources = lookup(statement.value, "not_resources", null) + sid = try(statement.value.sid, replace(statement.key, "/[^0-9A-Za-z]*/", "")) + effect = try(statement.value.effect, null) + actions = try(statement.value.actions, null) + not_actions = try(statement.value.not_actions, null) + resources = try(statement.value.resources, null) + not_resources = try(statement.value.not_resources, null) dynamic "principals" { - for_each = lookup(statement.value, "principals", []) + for_each = try(statement.value.principals, []) content { type = principals.value.type identifiers = principals.value.identifiers @@ -362,7 +362,7 @@ data "aws_iam_policy_document" "additional_inline" { } dynamic "not_principals" { - for_each = lookup(statement.value, "not_principals", []) + for_each = try(statement.value.not_principals, []) content { type = not_principals.value.type identifiers = not_principals.value.identifiers @@ -370,7 +370,7 @@ data "aws_iam_policy_document" "additional_inline" { } dynamic "condition" { - for_each = lookup(statement.value, "condition", []) + for_each = try(statement.value.condition, []) content { test = condition.value.test variable = condition.value.variable diff --git a/main.tf b/main.tf index 5296554c..fe32f7e0 100644 --- a/main.tf +++ b/main.tf @@ -13,9 +13,9 @@ locals { was_missing = var.local_existing_package != null ? !fileexists(var.local_existing_package) : local.archive_was_missing # s3_* - to get package from S3 - s3_bucket = var.s3_existing_package != null ? lookup(var.s3_existing_package, "bucket", null) : (var.store_on_s3 ? var.s3_bucket : null) - s3_key = var.s3_existing_package != null ? lookup(var.s3_existing_package, "key", null) : (var.store_on_s3 ? var.s3_prefix != null ? format("%s%s", var.s3_prefix, replace(local.archive_filename_string, "/^.*//", "")) : replace(local.archive_filename_string, "/^\\.//", "") : null) - s3_object_version = var.s3_existing_package != null ? lookup(var.s3_existing_package, "version_id", null) : (var.store_on_s3 ? try(aws_s3_object.lambda_package[0].version_id, null) : null) + s3_bucket = var.s3_existing_package != null ? try(var.s3_existing_package.bucket, null) : (var.store_on_s3 ? var.s3_bucket : null) + s3_key = var.s3_existing_package != null ? try(var.s3_existing_package.key, null) : (var.store_on_s3 ? var.s3_prefix != null ? format("%s%s", var.s3_prefix, replace(local.archive_filename_string, "/^.*//", "")) : replace(local.archive_filename_string, "/^\\.//", "") : null) + s3_object_version = var.s3_existing_package != null ? try(var.s3_existing_package.version_id, null) : (var.store_on_s3 ? try(aws_s3_object.lambda_package[0].version_id, null) : null) } @@ -204,12 +204,12 @@ resource "aws_lambda_permission" "current_version_triggers" { function_name = aws_lambda_function.this[0].function_name qualifier = aws_lambda_function.this[0].version - statement_id = lookup(each.value, "statement_id", each.key) - action = lookup(each.value, "action", "lambda:InvokeFunction") - principal = lookup(each.value, "principal", format("%s.amazonaws.com", lookup(each.value, "service", ""))) - source_arn = lookup(each.value, "source_arn", null) - source_account = lookup(each.value, "source_account", null) - event_source_token = lookup(each.value, "event_source_token", null) + statement_id = try(each.value.statement_id, each.key) + action = try(each.value.action, "lambda:InvokeFunction") + principal = try(each.value.principal, format("%s.amazonaws.com", try(each.value.service, ""))) + source_arn = try(each.value.source_arn, null) + source_account = try(each.value.source_account, null) + event_source_token = try(each.value.event_source_token, null) } # Error: Error adding new Lambda Permission for lambda: InvalidParameterValueException: We currently do not support adding policies for $LATEST. @@ -218,12 +218,12 @@ resource "aws_lambda_permission" "unqualified_alias_triggers" { function_name = aws_lambda_function.this[0].function_name - statement_id = lookup(each.value, "statement_id", each.key) - action = lookup(each.value, "action", "lambda:InvokeFunction") - principal = lookup(each.value, "principal", format("%s.amazonaws.com", lookup(each.value, "service", ""))) - source_arn = lookup(each.value, "source_arn", null) - source_account = lookup(each.value, "source_account", null) - event_source_token = lookup(each.value, "event_source_token", null) + statement_id = try(each.value.statement_id, each.key) + action = try(each.value.action, "lambda:InvokeFunction") + principal = try(each.value.principal, format("%s.amazonaws.com", try(each.value.service, ""))) + source_arn = try(each.value.source_arn, null) + source_account = try(each.value.source_account, null) + event_source_token = try(each.value.event_source_token, null) } resource "aws_lambda_event_source_mapping" "this" { @@ -233,21 +233,21 @@ resource "aws_lambda_event_source_mapping" "this" { event_source_arn = each.value.event_source_arn - batch_size = lookup(each.value, "batch_size", null) - maximum_batching_window_in_seconds = lookup(each.value, "maximum_batching_window_in_seconds", null) - enabled = lookup(each.value, "enabled", null) - starting_position = lookup(each.value, "starting_position", null) - starting_position_timestamp = lookup(each.value, "starting_position_timestamp", null) - parallelization_factor = lookup(each.value, "parallelization_factor", null) - maximum_retry_attempts = lookup(each.value, "maximum_retry_attempts", null) - maximum_record_age_in_seconds = lookup(each.value, "maximum_record_age_in_seconds", null) - bisect_batch_on_function_error = lookup(each.value, "bisect_batch_on_function_error", null) - topics = lookup(each.value, "topics", null) - queues = lookup(each.value, "queues", null) - function_response_types = lookup(each.value, "function_response_types", null) + batch_size = try(each.value.batch_size, null) + maximum_batching_window_in_seconds = try(each.value.maximum_batching_window_in_seconds, null) + enabled = try(each.value.enabled, null) + starting_position = try(each.value.starting_position, null) + starting_position_timestamp = try(each.value.starting_position_timestamp, null) + parallelization_factor = try(each.value.parallelization_factor, null) + maximum_retry_attempts = try(each.value.maximum_retry_attempts, null) + maximum_record_age_in_seconds = try(each.value.maximum_record_age_in_seconds, null) + bisect_batch_on_function_error = try(each.value.bisect_batch_on_function_error, null) + topics = try(each.value.topics, null) + queues = try(each.value.queues, null) + function_response_types = try(each.value.function_response_types, null) dynamic "destination_config" { - for_each = lookup(each.value, "destination_arn_on_failure", null) != null ? [true] : [] + for_each = try(each.value.destination_arn_on_failure, null) != null ? [true] : [] content { on_failure { destination_arn = each.value["destination_arn_on_failure"] @@ -256,7 +256,7 @@ resource "aws_lambda_event_source_mapping" "this" { } dynamic "source_access_configuration" { - for_each = lookup(each.value, "source_access_configuration", []) + for_each = try(each.value.source_access_configuration, []) content { type = source_access_configuration.value["type"] uri = source_access_configuration.value["uri"] @@ -264,11 +264,11 @@ resource "aws_lambda_event_source_mapping" "this" { } dynamic "filter_criteria" { - for_each = lookup(each.value, "filter_criteria", null) != null ? [true] : [] + for_each = try(each.value.filter_criteria, null) != null ? [true] : [] content { filter { - pattern = lookup(each.value["filter_criteria"], "pattern", null) + pattern = try(each.value["filter_criteria"].pattern, null) } } } diff --git a/modules/alias/main.tf b/modules/alias/main.tf index 3ba9c537..859c125a 100644 --- a/modules/alias/main.tf +++ b/modules/alias/main.tf @@ -87,12 +87,12 @@ resource "aws_lambda_permission" "version_triggers" { # Error: Error adding new Lambda Permission for ... InvalidParameterValueException: We currently do not support adding policies for $LATEST. qualifier = local.version != "$LATEST" ? local.version : null - statement_id = lookup(each.value, "statement_id", each.key) - action = lookup(each.value, "action", "lambda:InvokeFunction") - principal = lookup(each.value, "principal", format("%s.amazonaws.com", lookup(each.value, "service", ""))) - source_arn = lookup(each.value, "source_arn", null) - source_account = lookup(each.value, "source_account", null) - event_source_token = lookup(each.value, "event_source_token", null) + statement_id = try(each.value.statement_id, each.key) + action = try(each.value.action, "lambda:InvokeFunction") + principal = try(each.value.principal, format("%s.amazonaws.com", try(each.value.service, ""))) + source_arn = try(each.value.source_arn, null) + source_account = try(each.value.source_account, null) + event_source_token = try(each.value.event_source_token, null) } resource "aws_lambda_permission" "qualified_alias_triggers" { @@ -101,10 +101,10 @@ resource "aws_lambda_permission" "qualified_alias_triggers" { function_name = var.function_name qualifier = var.name - statement_id = lookup(each.value, "statement_id", each.key) - action = lookup(each.value, "action", "lambda:InvokeFunction") - principal = lookup(each.value, "principal", format("%s.amazonaws.com", lookup(each.value, "service", ""))) - source_arn = lookup(each.value, "source_arn", null) - source_account = lookup(each.value, "source_account", null) - event_source_token = lookup(each.value, "event_source_token", null) + statement_id = try(each.value.statement_id, each.key) + action = try(each.value.action, "lambda:InvokeFunction") + principal = try(each.value.principal, format("%s.amazonaws.com", try(each.value.service, ""))) + source_arn = try(each.value.source_arn, null) + source_account = try(each.value.source_account, null) + event_source_token = try(each.value.event_source_token, null) } diff --git a/modules/alias/versions.tf b/modules/alias/versions.tf index 7c107841..d56fc0e8 100644 --- a/modules/alias/versions.tf +++ b/modules/alias/versions.tf @@ -2,6 +2,9 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.35" + aws = { + source = "hashicorp/aws" + version = ">= 3.35" + } } } diff --git a/modules/deploy/README.md b/modules/deploy/README.md index 7a190794..7064c86f 100644 --- a/modules/deploy/README.md +++ b/modules/deploy/README.md @@ -102,16 +102,16 @@ module "lambda" { |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | | [aws](#requirement\_aws) | >= 3.35 | -| [local](#requirement\_local) | >= 1 | -| [null](#requirement\_null) | >= 2 | +| [local](#requirement\_local) | >= 1.0 | +| [null](#requirement\_null) | >= 2.0 | ## Providers | Name | Version | |------|---------| | [aws](#provider\_aws) | >= 3.35 | -| [local](#provider\_local) | >= 1 | -| [null](#provider\_null) | >= 2 | +| [local](#provider\_local) | >= 1.0 | +| [null](#provider\_null) | >= 2.0 | ## Modules diff --git a/modules/deploy/versions.tf b/modules/deploy/versions.tf index 232880f0..deb3cfd9 100644 --- a/modules/deploy/versions.tf +++ b/modules/deploy/versions.tf @@ -2,8 +2,17 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.35" - local = ">= 1" - null = ">= 2" + aws = { + source = "hashicorp/aws" + version = ">= 3.35" + } + local = { + source = "hashicorp/local" + version = ">= 1.0" + } + null = { + source = "hashicorp/null" + version = ">= 2.0" + } } } diff --git a/versions.tf b/versions.tf index e54af37b..74f13846 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 4.8.0" + version = ">= 4.8" } external = { source = "hashicorp/external" From 295956f4217b5812c4f6f8d5395acfbc0a50a2bd Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 28 Mar 2022 08:20:05 +0000 Subject: [PATCH 3/3] chore(release): version 3.0.0 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## [3.0.0](https://github.com/terraform-aws-modules/terraform-aws-lambda/compare/v2.36.0...v3.0.0) (2022-03-28) ### ⚠ BREAKING CHANGES * Updated AWS provider to version 4.8 (#296) ### Features * Added support for ephemeral storage (requires AWS provider version 4.8.0) ([#291](https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/291)) ([f191bae](https://github.com/terraform-aws-modules/terraform-aws-lambda/commit/f191baea053e126fc6b83a2ea4d6988c4f47ebde)) * Updated AWS provider to version 4.8 ([#296](https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/296)) ([d4b55a8](https://github.com/terraform-aws-modules/terraform-aws-lambda/commit/d4b55a8bb142a7124f4cd910d68a631d9658260e)), closes [#291](https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/291) --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba9286f7..1ea3668a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ All notable changes to this project will be documented in this file. +## [3.0.0](https://github.com/terraform-aws-modules/terraform-aws-lambda/compare/v2.36.0...v3.0.0) (2022-03-28) + + +### ⚠ BREAKING CHANGES + +* Updated AWS provider to version 4.8 (#296) + +### Features + +* Added support for ephemeral storage (requires AWS provider version 4.8.0) ([#291](https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/291)) ([f191bae](https://github.com/terraform-aws-modules/terraform-aws-lambda/commit/f191baea053e126fc6b83a2ea4d6988c4f47ebde)) +* Updated AWS provider to version 4.8 ([#296](https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/296)) ([d4b55a8](https://github.com/terraform-aws-modules/terraform-aws-lambda/commit/d4b55a8bb142a7124f4cd910d68a631d9658260e)), closes [#291](https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/291) + ## [2.36.0](https://github.com/terraform-aws-modules/terraform-aws-lambda/compare/v2.35.1...v2.36.0) (2022-03-26)