Code Monkey home page Code Monkey logo

terraform-aws-lambda's Introduction

Lambda function

latest release build status

This module creates a lambda function and takes care of setting up the execution role, in addition to uploading the source code. Note that source_code_hash or s3_object_version must be set if you want to automatically update the Lambda execution code.

terraform-aws-lambda's People

Contributors

codigube avatar dependabot[bot] avatar itsdalmo avatar jentz avatar macrofish avatar mhd999 avatar mikael-lindstrom avatar monckdav avatar paulerickson avatar rickardl avatar sadrig91 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-aws-lambda's Issues

Module requires at least one environment variable - is marked as 'optional' in documentation

Bug report

Cannot use module without setting the environement variable.
environement is marked as an optional field in the documentation.

The module only works if environement is set with at least one actual variable.
Can not be set as null or an empty object.

Steps to reproduce

Create a new module without environment set.

module "main" {
  source = "telia-oss/lambda/aws"
  version = "3.1.0"

  name_prefix = "hello-world"
  policy = data.aws_iam_policy_document.main.json

  s3_bucket = "my-bucket"
  s3_key = "my-function.zip"

  handler = "handler.handler"
  runtime = "nodejs12.x"
}

Terraform version

$ terraform version

Terraform v0.14.5
+ provider registry.terraform.io/hashicorp/aws v3.25.0

Create basic lambda failed with S3 object validation error

Issue

When you trying to create basic lambda function using this template it failed with error Failed getting S3 object: InvalidParameter: 2 validation error(s) found. This issue is causing by aws_s3_bucket_object which terraform trying to define in every kind of lambdas.

Versions

Terraform v0.11.11 + provider.aws v2.6.0

Step to reproduce

Provision basic lambda (without VPC or S3) using a default example at folder examples/default

$ terraform init
Initializing modules...
- module.lambda
Initializing provider plugins...
Terraform has been successfully initialized!

$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.aws_s3_bucket_object.main: Refreshing state...
data.aws_iam_policy_document.assume: Refreshing state...
data.aws_iam_policy_document.lambda: Refreshing state...

Error: Error refreshing state: 1 error(s) occurred:

* module.lambda.data.aws_s3_bucket_object.main: 1 error(s) occurred:

* module.lambda.data.aws_s3_bucket_object.main: data.aws_s3_bucket_object.main: Failed getting S3 object: InvalidParameter: 2 validation error(s) found.
- minimum field size of 1, HeadObjectInput.Bucket.
- minimum field size of 1, HeadObjectInput.Key.
 Bucket: "" Object: ""

Fix

A possible way how to fix the issue can be added the count meta-argument to the aws_s3_bucket_object main object as well.

https://github.com/telia-oss/terraform-aws-lambda/blob/0.3.4/main.tf#L67

data "aws_s3_bucket_object" "main" {
  count  = "${var.filename == "" ? 1 : 0}"
  bucket = "${var.s3_bucket}"
  key    = "${var.s3_key}"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.