Skip to content

Repository files navigation

Terraform AWS lambda

This module implements Lambda functionality in AWS with all known best practices with regards to logging and security.

How does it work

First use after you clone this repository or when .pre-commit-config.yaml is updated

Run pre-commit install to install any guardrails implemented using pre-commit.

See pre-commit installation on how to install pre-commit.

Usage

See the examples of some basic scenarios.

The artifact hash is ignored when ECR is used for compatibility with CI/CD setups.

Future work

The local setup (uploading of .zip) should be replaced by a dedicated S3 bucket because this method is an improvement in every aspect over local uploads.

Providers

NameVersion
archiven/a
aws>=4.21.0

Modules

NameSourceVersion
default_exec_rolegit@github.com:wearetechnative/terraform-aws-iam-role9a975f62956b6c4f2593c169d06d1cfe8aad36be

Resources

NameType
aws_cloudwatch_log_group.cloudwatch_logsresource
aws_iam_policy.cloudwatch_logsresource
aws_iam_policy.sqs_dlqresource
aws_iam_policy.vpcresource
aws_iam_role_policy_attachment.cloudwatch_logsresource
aws_iam_role_policy_attachment.sqs_dlqresource
aws_iam_role_policy_attachment.vpcresource
aws_lambda_function.thisresource
aws_lambda_function_event_invoke_config.thisresource
archive_file.lambda_sourcedata source
aws_caller_identity.currentdata source
aws_iam_policy_document.cloudwatch_logsdata source
aws_iam_policy_document.sqs_dlqdata source
aws_iam_policy_document.vpcdata source
aws_partition.currentdata source
aws_region.currentdata source
aws_security_group.vpcdata source
aws_subnet.vpcdata source

Inputs

NameDescriptionTypeDefaultRequired
architectureArchitecture for Lambda function can be either x86_64 or arm64. Defaults to x86_64.string"x86_64"no
environment_variablesKey value map of environment variables.map(string){}no
handlerEntrypoint in the application. Defaults to index.handler.string"index.handler"no
kms_key_arnKMS key to use for encrypting RDS instances.stringn/ayes
memory_sizeLambda memory size. Defaults to 128.number128no
namePrefix name for DynamoDB. Must be unique within the region.stringn/ayes
role_arnExec role for Lambda function.stringnullno
role_arn_providedWorkaround TerraForm limitation. Set to true if var.role_arn is set, otherwise false.boolfalseno
runtimeLambda runtime which must be set when var.source_type is s3 or local.stringnullno
security_group_idsSecurity group IDs if VPC connectivity is required. Requires var.subnet_ids to be set too.list(string)[]no
source_directory_locationECR location URL, S3 bucket or directory path depending on the value of var.source_type.stringn/ayes
source_file_nameECR tag, S3 key or null (local) depending on the value of var.source_type.stringn/ayes
source_typeIs set to either ecr, s3 or local. Currently only supports ecr and local.string"ecr"no
sqs_dlq_arnDead Letter Queue for on_failure delivery of invocationsstringn/ayes
subnet_idsSubnet IDs if VPC connectivity is required. Requires var.security_group_ids to be set too.list(string)[]no
timeoutLambda timeout. Defaults to 3 seconds.number3no

Outputs

NameDescription
lambda_function_arnn/a
lambda_function_namen/a

About

This module implements Lambda functionality in AWS with all known best practices with regards to logging and security.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages