/terraform-aws-lambda

Deploy serverless function to AWS VPC

Primary LanguageHCLMIT LicenseMIT

AWS Lambda

Deploy Lambda into VPC or outside of the VPC.


Maintenance GitHub forks


Usage example

Here's the gist of using it via github.

module "lambda" {
  source  = "terraform-module/lambda/aws"
  version = "~> 2"

  function_name      = "lambda-name-to-deploy"
  filename            = "${path.module}/lambda.zip"
  description        = "description should be here"
  handler            = "index.handler"
  runtime            = "nodejs12.x"
  memory_size        = "128"
  concurrency        = "5"
  lambda_timeout     = "20"
  log_retention      = "1"
  role_arn           = "some-role-arn"
  tracing_config      = { mode = "Active" }

  vpc_config = {
    subnet_ids         = ["sb-q53asdfasdfasdf", "sf-3asdfasdfasdf6"]
    security_group_ids = ["sg-3asdfadsfasdfas"]
  }

  environment = {
    Environment = "test"
  }

  tags = {
    Environment = "test"
  }
}

Module Variables

Requirements

Name Version
terraform >= 0.12.9
aws >= 2.5

Providers

Name Version
aws >= 2.5

Inputs

Name Description Type Default Required
concurrency The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. number n/a yes
description Description of what your Lambda Function does. string n/a yes
environment The Lambda environment's configuration settings. map(string) null no
event_age_in_seconds Maximum age of a request that Lambda sends to a function for processing in seconds. Valid values between 60 and 21600. number 100 no
filename The path to the function's deployment package within the local filesystem. If defined. No S3 support string n/a yes
function_name A unique name for your Lambda Function. string n/a yes
handler The function entrypoint in your code. string n/a yes
lambda_timeout The amount of time your Lambda Function has to run in seconds. Defaults to 5 number 5 no
layers List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function list(string) null no
log_retention Specifies the number of days you want to retain log events in the specified log group. number 1 no
memory_size Amount of memory in MB your Lambda Function can use at runtime. Defaults to 128. number n/a yes
publish Whether to publish creation/change as new Lambda Function Version. Defaults to true. bool true no
retry_attempts Maximum number of times to retry when the function returns an error. Valid values between 0 and 2. Defaults to 0. number 0 no
role_arn IAM role attached to the Lambda Function. This governs both who / what can invoke your Lambda Function, as well as what resources our Lambda Function has access to. string n/a yes
runtime See Runtimes for valid values. string n/a yes
source_code_hash Used to trigger updates when file contents change. Must be set to a base64-encoded SHA256 hash of the package file specified with either filename or s3_key. string null no
tags A mapping of tags to assign to the object. map {} no
tracing_config Use AWS X-Ray to collect data about events that your function processes, and to identify the cause of errors in your serverless applications. Can be either PassThrough or Active.
object({
mode = string
})
null no
vpc_config Provide this to allow your function to access your VPC. Fields documented below. See Lambda in VPC.
object({
security_group_ids = list(string)
subnet_ids = list(string)
})
null no
file_system_config Provide this to allow your function to mount your EFS file system. Fields documented below. See Lambda with EFS.
{
efs_access_point_arn = string
local_mount_path = string
}
null no

Outputs

Name Description
arn Lambda ARN
cloudwatch_logs_arn The arn of theh log group.
cloudwatch_logs_name The name of the log group.
invoke_arn ARN to invoke the lambda method
name Lambda Name
version Lambda Version

Commands

$ make help
hooks                          Commit hooks setup
validate                       Validate with pre-commit hooks
changelog                      Update changelog

📝 Guidelines

  • 📝 Use a succinct title and description.
  • 🐛 Bugs & feature requests can be be opened
  • 📶 Support questions are better asked on Stack Overflow
  • 😊 Be nice, civil and polite (as always).

License

Copyright 2019 Ivan Katliarhcuk

MIT Licensed. See LICENSE for full details.

How to Contribute

Submit a pull request

Authors

Currently maintained by Ivan Katliarchuk and these awesome contributors.

ForTheBadge uses-git

Terraform Registry