terraform-aws-modules/terraform-aws-lambda

Unnecessary Poetry install build step

moranimu opened this issue · 7 comments

Description

Since version 4.3.0 we encountered that when trying to package Poetry dependencies, a new build step is added to the build plan - poetry install, even though we did not set poetry_install = true.

  • ✋ I have searched the open/closed issues and my issue is not listed.

Versions

  • Module version: 4.3.0 and further
    Terraform v1.0.8
    on linux_amd64
  • provider registry.terraform.io/hashicorp/aws v4.58.0
  • provider registry.terraform.io/hashicorp/external v2.3.1
  • provider registry.terraform.io/hashicorp/local v2.4.0
  • provider registry.terraform.io/hashicorp/null v3.2.1

Reproduction Code [Required]

  1. Create a Poetry project in your module with .toml and .lock
  2. run terraform apply

Steps to reproduce the behavior:

Expected behavior

a build_plan that includes only pip install

Actual behavior

A build plan includes 2 steps: pip install (required) and poverty install (not required)

Terminal Output Screenshot(s)

build_plan = [
[
"pip",
"python3.8",
"/builds/lambda/requirements.txt",
,
,
],
[
"poetry",
"python3.8",
"/builds/lambda",
,
],
[
"zip",
"/builds/lambda",
,
],
]

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

Any update on this issue?

@pdecat What do you think about this issue?

pdecat commented

Went under my radar, I'll look into it.

pdecat commented

Hi @moranimu,

Since version 4.3.0 we encountered that when trying to package Poetry dependencies, a new build step is added to the build plan - poetry install, even though we did not set poetry_install = true.

poetry_install is only taken into account if the source_path parameter is passed as a dict.
When source_path is passed as a string pointing to a directory, discovery of the build system is automatically performed.
If both a requirements.txt file and a pyproject.toml file defining poetry as the build system are present, both dependencies managers are executed.
Maybe this should be changed to only process the first dependencies manager found. But triggering both maybe actually be desired in some cases.

In the meantime, you should be able to restore previous behavior by converting the source_path field from a string into a dict, e.g.:

Before:

  source_path = "${path.module}/../fixtures/python3.8-app1"

After:

  source_path = [
    {
      path             = "${path.module}/../fixtures/python3.8-app1"
      pip_requirements = "true"
    }
  ]

This issue has been resolved in version 4.16.0 🎉

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.