FEATURES PRICING ABOUT DOCS LOGIN

aws_lambda_function

Provides a Lambda Function resource. Lambda allows you to trigger execution of code in response to events in AWS. The Lambda Function itself includes source code and runtime configuration.

For information about Lambda and how to use it, see What is AWS Lambda?

Example Usage

resource "aws_iam_role" "iam_for_lambda" {
    name = "iam_for_lambda"
    assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "lambda.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
EOF
}

resource "aws_lambda_function" "test_lambda" {
    filename = "lambda_function_payload.zip"
    function_name = "lambda_function_name"
    role = "${aws_iam_role.iam_for_lambda.arn}"
    handler = "exports.test"
    source_code_hash = "${base64sha256(file("lambda_function_payload.zip"))}"
}

Argument Reference

vpc_config requires the following:

~> NOTE: if both subnet_ids and security_group_ids are empty then vpc_config is considered to be empty or unset.

Attributes Reference

Import

Lambda Functions can be imported using the function_name, e.g.

$ terraform import aws_lambda_function.tesr_lambda my_test_lambda_function

See the source of this document at Terraform.io

REQUEST A DEMO