Could not locate source_path "null" despite create_function = false
DuncanKwokTR opened this issue · 4 comments
Description
I already have zipped my own package and do not require create_function, so it is set to false.
Yet despite that, module is looking to for source_path of the deployment.
It is already given local_existing_package = "file.zip"
module "r53_lambda_function_externally_managed_package" {
source = "../../Resource_modules/lambda/"
create_function = true # to control creation of the Lambda Function and related resources
create_package = false # to control build package process
create_layer = false # to control creation of the Lambda Layer and related resources
create_role = true # to control creation of the IAM role and policies required for Lambda Function
function_name = local.vds_lambda_function_name
description = "My lambda function code is deployed separately"
handler = var.vds_lambda_handler
runtime = var.vds_lambda_runtime
ignore_source_code_hash = true
vpc_security_group_ids = [module.r53_security_group.security_group]
vpc_subnet_ids = var.vds_lambda_subnet_ids
attach_cloudwatch_logs_policy = false
attach_dead_letter_policy = false
attach_network_policy = false
attach_tracing_policy = false
attach_async_event_policy = false
local_existing_package = var.vds_lambda_filename
Depsite asking not to create package...
source_path = local.source_path
source_path = "../../../lambda_python/healthcheck.zip"
// IAM Role Create
role_path = local.iam_lambda_role_path
role_name = local.iam_lambda_role_name
role_description = local.iam_lambda_role_description
role_permissions_boundary = local.iam_lambda_role_permissions_boundary_arn
role_force_detach_policies = local.iam_lambda_force_detach_policies
// IAM Policy Create
policy_name = local.iam_lambda_policy_name
policy_path = local.iam_lambda_policy_path
policy_json = local.iam_lambda_policy
// IAM Policy Attachment
attach_policy_json = true
}
Looking at the main.tf module, I see only 2 references to source_path
resource "null_resource" "sam_metadata_aws_lambda_function" {
count = local.create && var.create_package && var.create_function && !var.create_layer ? 1 : 0
resource "null_resource" "sam_metadata_aws_lambda_layer_version" {
count = local.create && var.create_package && var.create_layer ? 1 : 0
To my understanding, if create_package = false, source_path should not even be required and will be null.
If your request is for a new feature, please use the Feature request
template.
-
✋ I have searched the open/closed issues and my issue is not listed.
⚠️ Note
Before you submit an issue, please perform the following first:
- Remove the local
.terraform
directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!):rm -rf .terraform/
- Re-initialize the project root to pull down modules:
terraform init
- Re-attempt your terraform plan or apply and check if the issue still persists
Versions
-
Module version [Required]: 4.8
-
Terraform version:
Terraform v1.3.6
on linux_amd64 -
Provider version(s):
Terraform v1.3.6
on linux_amd64
- provider registry.terraform.io/hashicorp/aws v4.51.0
- provider registry.terraform.io/hashicorp/external v2.2.3
- provider registry.terraform.io/hashicorp/local v2.3.0
- provider registry.terraform.io/hashicorp/null v3.2.1
Reproduction Code [Required]
Steps to reproduce the behavior:
no yescall the resource module to create lambda function that has externally managed package and don;t build it from source.
Expected behavior
Skip the creation of the package.
Actual behavior
it is looking asking for source_path, despite create_function = false.
Terminal Output Screenshot(s)
│ Error: External Program Execution Failed
│
│ with module.r53_lambda_permission.data.external.archive_prepare[0],
│ on ../../Resource_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: /usr/local/bin/python3
│ Error Message: Could not locate source_path "null". Paths are relative to directory where terraform plan
is being run
│ ("/home/users/gitprojects/Infrastructure_modules/cloud_container_infrastructure")
It says paths are relative, but in variables.tf, it says absolute path.
variable "source_path" {
description = "The absolute path to a local file or directory containing your Lambda source code"
type = any # string | list(string | map(any))
default = null
}
I've also tried to set create_function = true but it can never find my source through source_path even though it is correct.
Additional context
Apologies, in my original post, i wrote source_path = "../../../lambda_python/healthcheck.zip"
It is supposed to be simply source_path = "../../../lambda_python" but still didnt work.
This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days
This issue was automatically closed because of stale in 10 days