tomarv2 / terraform-aws-lambda

Terraform module to deploy AWS Lambda.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform module for AWS Lambda

Versions

  • Module tested for Terraform 1.0.1.
  • AWS provider version 4.35.
  • main branch: Provider versions not pinned to keep up with Terraform releases.
  • tags releases: Tags are pinned with versions (use ).

Usage

Option 1:

terrafrom init
terraform plan -var='teamid=tryme' -var='prjid=project1'
terraform apply -var='teamid=tryme' -var='prjid=project1'
terraform destroy -var='teamid=tryme' -var='prjid=project1'

Note: With this option please take care of remote state storage

Option 2:

Recommended method (stores remote state in remote backend(S3, Azure storage, or Google bucket) using prjid and teamid to create directory structure):
  • Create python 3.8+ virtual environment
python3 -m venv <venv name>
  • Install package:
pip install tfremote --upgrade
  • Set below environment variables:
export TF_AWS_BUCKET=<remote state bucket name>
export TF_AWS_BUCKET_REGION=us-west-2
export TF_AWS_PROFILE=<profile from ~/.ws/credentials>

or

  • Set below environment variables:
export TF_AWS_BUCKET=<remote state bucket name>
export TF_AWS_BUCKET_REGION=us-west-2
export AWS_ACCESS_KEY_ID=<aws_access_key_id>
export AWS_SECRET_ACCESS_KEY=<aws_secret_access_key>
  • Updated examples directory with required values.

  • Run and verify the output before deploying:

tf -c=aws plan -var='teamid=foo' -var='prjid=bar'
  • Run below to deploy:
tf -c=aws apply -var='teamid=foo' -var='prjid=bar'
  • Run below to destroy:
tf -c=aws destroy -var='teamid=foo' -var='prjid=bar'

Note: Read more on tfremote

Please refer to examples directory link for references.

Requirements

Name Version
terraform >= 1.0.1
archive >= 2.1
aws ~> 4.35
external >= 2.1.0
null >= 3.1.0

Providers

Name Version
archive >= 2.1
aws ~> 4.35
external >= 2.1.0

Modules

No modules.

Resources

Name Type
aws_lambda_function.lambda resource
archive_file.zip data source
external_external.install_python_dependencies data source

Inputs

Name Description Type Default Required
config Lambda configuration map(any) {} no
extra_tags Additional tags to associate map(string) {} no

Outputs

Name Description
arn ARN of the Lambda function
function_name Name of the Lambda function
output_path Output file path location
output_size Output file size
source_dir Source code location
source_file Lambda source code location

About

Terraform module to deploy AWS Lambda.

License:Apache License 2.0


Languages

Language:HCL 81.4%Language:Python 18.6%