terraform-aws-modules / terraform-aws-lambda

Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/lambda/aws
Apache License 2.0
886 stars 657 forks source link

Unnecessary Poetry install build step #436

Closed moranimu closed 1 year ago

moranimu commented 1 year ago

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.

Versions

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", , ], ]

github-actions[bot] commented 1 year ago

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

moranimu commented 1 year ago

Any update on this issue?

antonbabenko commented 1 year ago

@pdecat What do you think about this issue?

pdecat commented 1 year ago

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

pdecat commented 1 year ago

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"
    }
  ]
antonbabenko commented 1 year ago

This issue has been resolved in version 4.16.0 :tada:

github-actions[bot] commented 1 year ago

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.