terraform-aws-modules/terraform-aws-lambda

Error creating lambda: Could not locate source_path "null"

darioackermann opened this issue · 3 comments

Description

terraform plan fails with

Plan: 4 to add, 0 to change, 0 to destroy.
╷
│ Error: invalid value for name (must match [\w+=,.@-])
│
│   with module.lambda.aws_iam_role.lambda[0],
│   on .terraform\modules\lambda\iam.tf line 97, in resource "aws_iam_role" "lambda":
│   97:   name                  = local.role_name
│
╵
╷
│ Error: invalid value for name (must match [\w+=,.@-])
│
│   with module.lambda.aws_iam_policy.logs[0],
│   on .terraform\modules\lambda\iam.tf line 137, in resource "aws_iam_policy" "logs":
│  137:   name   = "${local.policy_name}-logs"
│
╵
╷
│ Error: External Program Execution Failed
│
│   with module.lambda.data.external.archive_prepare[0],
│   on .terraform\modules\lambda\package.tf line 10, in data "external" "archive_prepare":
│   10:   program = [local.python, "${path.module}/package.py", "prepare"]
│
│ The data source received an unexpected error while attempting to execute the program.
│
│ Program: C:\Users\a\AppData\Local\Programs\Python\Python310\python.exe
│ Error Message: Could not locate source_path "null".  Paths are relative to directory where `terraform plan` is being
│ run ("C:\Users\a\easteregg\terraform")
│
│ State: exit status 1

My issue is listed, here, but it was closed
#440

Versions

  • Module version [Required]: 6.5.0

  • Terraform version: 1.5.7

  • Provider version(s):

+ provider registry.terraform.io/hashicorp/aws v5.31.0
+ provider registry.terraform.io/hashicorp/external v2.3.2
+ provider registry.terraform.io/hashicorp/local v2.4.1
+ provider registry.terraform.io/hashicorp/null v3.2.2

Reproduction Code [Required]

module "lambda" {
  source  = "terraform-aws-modules/lambda/aws"
  version = "6.5.0"
}

# ...

module "lambda_function" {
  source = "terraform-aws-modules/lambda/aws"

  function_name = "easteregg"
  handler       = "app.lambda_handler"
  runtime       = "nodejs20.x"

  role_name = "easteregg"

  source_path      = "${path.module}/../src"

}

Steps to reproduce the behavior:

Expected behavior

  • source_path should not be none
  • role_names should be valid

Actual behavior

  • source_path seems to be none

Additional context

This is happening on Windows

I encountered some issues related to source_path when I updated to release v7.0.0 while using aws provider version 5.24.0, I'm not saying this will solve your issues but in my case a bunch of errors went away when I updated the aws provider to version 5.33.0

This code is wrong because there are not enough variables specified:

module "lambda" {
  source  = "terraform-aws-modules/lambda/aws"
  version = "6.5.0"
}

Please take a look at the examples for real and working examples.

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.