The TF module now supports Zip
and Image
deployment package types. When you use the Image
package type, you must not specify any value for the handler
, runtime
and layers
input variables.
AWS annouced the AWS parameters and secrets lambda extension on Oct 18, 2022. The extension is offered as a lambda layer and can be enabled by setting the use_parameters_and_secrets_layer
variable to true
.
module "function" {
source = "github.com/globeandmail/aws-lambda-function?ref=1.9"
function_name = "my-lambda-function"
tags = var.tags
# enable a dead letter queue
dead_letter_config = {
target_arn = "SQS or SNS arn"
}
}
Name | Description | Type | Default | Required |
---|---|---|---|---|
alias | Creates an alias that points to the specified Lambda function version | string |
"live" |
no |
dead_letter_config | n/a | object({ |
null |
no |
description | A description for this Lambda Function | string |
"Created by Terraform" |
no |
env_vars | A map that defines environment variables for this Lambda function. | map |
null |
no |
ephemeral_storage | Amount of Ephemeral storage(/tmp) in MB this Lambda Function can use at runtime. Defaults to 512 | number |
512 |
no |
filename | The zip file to upload containing the function code | string |
"" |
no |
function_name | A unique name for this Lambda Function | string |
n/a | yes |
handler | The function entrypoint. Only specify when var.package_type is Zip | string |
"lambda_function.lambda_handler" |
no |
image_uri | The ECR image URI containing the function's deployment package. Only specify when var.package_type is Image | string |
"" |
no |
layers | List of Lambda Layer Version ARNs (maximum of 5) to attach to this Lambda Function. Only specify when var.package_type is Zip | list |
[] |
no |
memory_size | Amount of memory in MB this Lambda Function can use at runtime. Defaults to 128 | number |
128 |
no |
package_type | Lambda deployment package type | string |
"Zip" |
no |
publish | Whether to publish creation/change as new Lambda Function Version. | bool |
true |
no |
retention_in_days | Default value for this functions cloudwatch logs group | number |
14 |
no |
runtime | Lambda execution environment language. Only specify when var.package_type is Zip | string |
"python3.7" |
no |
secret_arn | The ARN of the Secrets Manager secret, including the 6 random characters at the end | string |
null |
no |
security_group_ids | Required for running this Lambda function in a VPC | list |
[] |
no |
sns_target_arn | SNS arn for the target when there is a failure | string |
"" |
no |
sqs_target_arn | SQS arn for the target when there is a failure | string |
"" |
no |
subnet_ids | Required for running this Lambda function in a VPC | list |
[] |
no |
tags | A mapping of tags to assign to the resource | map |
{} |
no |
timeout | The amount of time this Lambda Function has to run in seconds | number |
5 |
no |
use_parameters_and_secrets_layer | Required to be set to true if using the AWS parameters and secrets lambda extension. Only specify when var.package_type is Zip | bool |
false |
no |
use_secrets | Required to be set to true if using secret_arn | bool |
false |
no |
Name | Description |
---|---|
function_arn | The ARN of the function created |
function_name | The name of the function created |
invoke_arn | The ARN to be used for invoking Lambda Function from API Gateway |
role_arn | The ARN of the role created |
role_id | The name of the role created |
version | The version of the function created |