Skip to content
Merged
Next Next commit
add support for ephemeral storage size configuration
  • Loading branch information
liortct committed Mar 26, 2022
commit 86447313a9604e187e1e3278cddaa3e99d8fc220
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ No modules.
| <a name="input_docker_pip_cache"></a> [docker\_pip\_cache](#input\_docker\_pip\_cache) | Whether to mount a shared pip cache folder into docker environment or not | `any` | `null` | no |
| <a name="input_docker_with_ssh_agent"></a> [docker\_with\_ssh\_agent](#input\_docker\_with\_ssh\_agent) | Whether to pass SSH\_AUTH\_SOCK into docker environment or not | `bool` | `false` | no |
| <a name="input_environment_variables"></a> [environment\_variables](#input\_environment\_variables) | A map that defines environment variables for the Lambda Function. | `map(string)` | `{}` | no |
| <a name="input_ephemeral_storage_size"></a> [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 |
| <a name="input_event_source_mapping"></a> [event\_source\_mapping](#input\_event\_source\_mapping) | Map of event source mapping | `any` | `{}` | no |
| <a name="input_file_system_arn"></a> [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 |
| <a name="input_file_system_local_mount_path"></a> [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 |
Expand Down
1 change: 1 addition & 0 deletions examples/ephemeral-stoage/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
builds/*
71 changes: 71 additions & 0 deletions examples/ephemeral-stoage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Ephemeral storage example

Example how to configure emphemeral storage size (`/tmp`).

## Usage

To run this example you need to execute:

```bash
$ terraform init
$ terraform plan
$ terraform apply
```

Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.8.0 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_random"></a> [random](#provider\_random) | >= 2 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_lambda_function"></a> [lambda\_function](#module\_lambda\_function) | ../../ | n/a |

## Resources

| Name | Type |
|------|------|
| [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |

## Inputs

No inputs.

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_lambda_cloudwatch_log_group_arn"></a> [lambda\_cloudwatch\_log\_group\_arn](#output\_lambda\_cloudwatch\_log\_group\_arn) | The ARN of the Cloudwatch Log Group |
| <a name="output_lambda_function_arn"></a> [lambda\_function\_arn](#output\_lambda\_function\_arn) | The ARN of the Lambda Function |
| <a name="output_lambda_function_invoke_arn"></a> [lambda\_function\_invoke\_arn](#output\_lambda\_function\_invoke\_arn) | The Invoke ARN of the Lambda Function |
| <a name="output_lambda_function_kms_key_arn"></a> [lambda\_function\_kms\_key\_arn](#output\_lambda\_function\_kms\_key\_arn) | The ARN for the KMS encryption key of Lambda Function |
| <a name="output_lambda_function_last_modified"></a> [lambda\_function\_last\_modified](#output\_lambda\_function\_last\_modified) | The date Lambda Function resource was last modified |
| <a name="output_lambda_function_name"></a> [lambda\_function\_name](#output\_lambda\_function\_name) | The name of the Lambda Function |
| <a name="output_lambda_function_qualified_arn"></a> [lambda\_function\_qualified\_arn](#output\_lambda\_function\_qualified\_arn) | The ARN identifying your Lambda Function Version |
| <a name="output_lambda_function_source_code_hash"></a> [lambda\_function\_source\_code\_hash](#output\_lambda\_function\_source\_code\_hash) | Base64-encoded representation of raw SHA-256 sum of the zip file |
| <a name="output_lambda_function_source_code_size"></a> [lambda\_function\_source\_code\_size](#output\_lambda\_function\_source\_code\_size) | The size in bytes of the function .zip file |
| <a name="output_lambda_function_version"></a> [lambda\_function\_version](#output\_lambda\_function\_version) | Latest published version of Lambda Function |
| <a name="output_lambda_layer_arn"></a> [lambda\_layer\_arn](#output\_lambda\_layer\_arn) | The ARN of the Lambda Layer with version |
| <a name="output_lambda_layer_created_date"></a> [lambda\_layer\_created\_date](#output\_lambda\_layer\_created\_date) | The date Lambda Layer resource was created |
| <a name="output_lambda_layer_layer_arn"></a> [lambda\_layer\_layer\_arn](#output\_lambda\_layer\_layer\_arn) | The ARN of the Lambda Layer without version |
| <a name="output_lambda_layer_source_code_size"></a> [lambda\_layer\_source\_code\_size](#output\_lambda\_layer\_source\_code\_size) | The size in bytes of the Lambda Layer .zip file |
| <a name="output_lambda_layer_version"></a> [lambda\_layer\_version](#output\_lambda\_layer\_version) | The Lambda Layer version |
| <a name="output_lambda_role_arn"></a> [lambda\_role\_arn](#output\_lambda\_role\_arn) | The ARN of the IAM role created for the Lambda Function |
| <a name="output_lambda_role_name"></a> [lambda\_role\_name](#output\_lambda\_role\_name) | The name of the IAM role created for the Lambda Function |
| <a name="output_local_filename"></a> [local\_filename](#output\_local\_filename) | The filename of zip archive deployed (if deployment was from local) |
| <a name="output_s3_object"></a> [s3\_object](#output\_s3\_object) | The map with S3 object data of zip archive deployed (if deployment was from S3) |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
27 changes: 27 additions & 0 deletions examples/ephemeral-stoage/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
provider "aws" {
region = "eu-west-1"

# Make it faster by skipping something
skip_get_ec2_platforms = true
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

resource "random_pet" "this" {
length = 2
}

module "lambda_function" {
source = "../../"

publish = true

function_name = "${random_pet.this.id}-lambda-ephemeral-stoage"
handler = "index.lambda_handler"
runtime = "python3.8"
ephemeral_storage = 10240

}

99 changes: 99 additions & 0 deletions examples/ephemeral-stoage/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Lambda Function
output "lambda_function_arn" {
description = "The ARN of the Lambda Function"
value = module.lambda_function.lambda_function_arn
}

output "lambda_function_invoke_arn" {
description = "The Invoke ARN of the Lambda Function"
value = module.lambda_function.lambda_function_invoke_arn
}

output "lambda_function_name" {
description = "The name of the Lambda Function"
value = module.lambda_function.lambda_function_name
}

output "lambda_function_qualified_arn" {
description = "The ARN identifying your Lambda Function Version"
value = module.lambda_function.lambda_function_qualified_arn
}

output "lambda_function_version" {
description = "Latest published version of Lambda Function"
value = module.lambda_function.lambda_function_version
}

output "lambda_function_last_modified" {
description = "The date Lambda Function resource was last modified"
value = module.lambda_function.lambda_function_last_modified
}

output "lambda_function_kms_key_arn" {
description = "The ARN for the KMS encryption key of Lambda Function"
value = module.lambda_function.lambda_function_kms_key_arn
}

output "lambda_function_source_code_hash" {
description = "Base64-encoded representation of raw SHA-256 sum of the zip file"
value = module.lambda_function.lambda_function_source_code_hash
}

output "lambda_function_source_code_size" {
description = "The size in bytes of the function .zip file"
value = module.lambda_function.lambda_function_source_code_size
}

# Lambda Layer
output "lambda_layer_arn" {
description = "The ARN of the Lambda Layer with version"
value = module.lambda_function.lambda_layer_arn
}

output "lambda_layer_layer_arn" {
description = "The ARN of the Lambda Layer without version"
value = module.lambda_function.lambda_layer_layer_arn
}

output "lambda_layer_created_date" {
description = "The date Lambda Layer resource was created"
value = module.lambda_function.lambda_layer_created_date
}

output "lambda_layer_source_code_size" {
description = "The size in bytes of the Lambda Layer .zip file"
value = module.lambda_function.lambda_layer_source_code_size
}

output "lambda_layer_version" {
description = "The Lambda Layer version"
value = module.lambda_function.lambda_layer_version
}

# IAM Role
output "lambda_role_arn" {
description = "The ARN of the IAM role created for the Lambda Function"
value = module.lambda_function.lambda_role_arn
}

output "lambda_role_name" {
description = "The name of the IAM role created for the Lambda Function"
value = module.lambda_function.lambda_role_name
}

# CloudWatch Log Group
output "lambda_cloudwatch_log_group_arn" {
description = "The ARN of the Cloudwatch Log Group"
value = module.lambda_function.lambda_cloudwatch_log_group_arn
}

# Deployment package
output "local_filename" {
description = "The filename of zip archive deployed (if deployment was from local)"
value = module.lambda_function.local_filename
}

output "s3_object" {
description = "The map with S3 object data of zip archive deployed (if deployment was from S3)"
value = module.lambda_function.s3_object
}
Empty file.
8 changes: 8 additions & 0 deletions examples/ephemeral-stoage/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_version = ">= 0.13.1"

required_providers {
aws = ">= 4.8.0"
random = ">= 2"
}
}
4 changes: 4 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.69"
version = ">= 4.8.0"
}
external = {
source = "hashicorp/external"
Expand Down