Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambda Zip function check only fails if both handler and runtime are missing #20574

Closed
tism opened this issue Aug 16, 2021 · 2 comments · Fixed by #20575
Closed

Lambda Zip function check only fails if both handler and runtime are missing #20574

tism opened this issue Aug 16, 2021 · 2 comments · Fixed by #20575
Labels
bug Addresses a defect in current functionality. service/lambda Issues and PRs that pertain to the lambda service.
Milestone

Comments

@tism
Copy link
Contributor

tism commented Aug 16, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform v1.0.4
on darwin_amd64

  • provider registry.terraform.io/hashicorp/archive v2.2.0
  • provider registry.terraform.io/hashicorp/aws v3.54.0

Affected Resource(s)

  • aws_lambda_function

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "3.54.0"
    }
  }
}

provider "aws" {
  region  = "ap-southeast-2"
}

variable "namespace" {
  default = "cats"
}

resource "aws_iam_role" "iam_for_lambda" {
  name = "${var.namespace}-function-role"

  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" "function" {
  function_name    = "${var.namespace}-function"
  handler          = "lambda_function.lambda_handler"
  filename         = data.archive_file.lambda.output_path
  source_code_hash = data.archive_file.lambda.output_base64sha256
  package_type     = "Zip"

  role             = aws_iam_role.iam_for_lambda.arn
  runtime          = "nodejs12.x"
  timeout          = 3
  memory_size      = 128
  publish          = true
}

data "archive_file" "lambda" {
  type        = "zip"
  output_path = "${path.module}/.tmp/lambda.zip"

  source {
    content  = <<-JS
      exports.handler = function(event, context, callback) {
         callback(null, {"hello": "world");
      }
    JS
    filename = "lambda_function.js"
  }
}

Debug Output

│ Error: error creating Lambda Function (1): ValidationException:
│ 	status code: 400, request id: efafc141-56d8-44ee-9a88-5aadf4e62528

Expected Behavior

Validate that both handler and runtime are present if the package_type is Zip

Actual Behavior

Lambda create is requested, fails with ValidationException

Steps to Reproduce

  1. Comment out a combination of handler and runtime
  2. terraform apply
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/iam Issues and PRs that pertain to the iam service. service/lambda Issues and PRs that pertain to the lambda service. labels Aug 16, 2021
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. and removed service/iam Issues and PRs that pertain to the iam service. needs-triage Waiting for first response or review from a maintainer. labels Aug 16, 2021
@github-actions github-actions bot added this to the v3.55.0 milestone Aug 17, 2021
@github-actions
Copy link

This functionality has been released in v3.55.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/lambda Issues and PRs that pertain to the lambda service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants