terraform-aws-modules/terraform-aws-lambda

poetry_install-option fails with ERROR: Hashes are required in --require-hashes mode

villekr opened this issue · 2 comments

Description

Deployment and deployed lambda function works as expected when I use 'source_path' with 'pip_requirements'. But with 'source_path' and 'poetry_install' I get the following error:

Collecting aioboto3==11.2.0
│   Using cached aioboto3-11.2.0-py3-none-any.whl (32 kB)
│ ERROR: Hashes are required in --require-hashes mode, but they are missing
│ from some requirements

pyproject.toml contains the following

[tool.poetry.dependencies]
python = "^3.10"
aioboto3 = "11.2.0"
  • [x ] I have searched the open/closed issues and my issue is not listed.

Versions

  • Module version [Required]: 4.18.0

  • Terraform version:
    Terraform v1.4.6
    on darwin_arm64

  • Provider version(s):

  • provider registry.terraform.io/hashicorp/aws v5.1.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
  • provider registry.terraform.io/hashicorp/random v3.5.1

Reproduction Code [Required]

My module definition is the following:

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

  function_name = join("-", [var.env, var.prefix, "lambda"])
  description   = "Python Lambda Function"

  handler = "lambda_function.lambda_handler"
  architectures = ["arm64"]
  runtime = "python3.10"
  timeout = "60"

  publish       = true

  # use Poetry and pyproject.toml
  source_path = [
    "../lang/python",
    {
      poetry_install = true
    }
  ]
  # use pip and requirements.txt
#  source_path = [
#    "../lang/python/lambda",
#    {
#      pip_requirements = "../lang/python/lambda/requirements.txt"
#    }
#  ]

  store_on_s3 = true
  s3_bucket   = aws_s3_bucket.this.bucket
}

Steps to reproduce the behavior:

No (but I'm using terragrunt for deployment) Yes 'terragrunt apply' fails

Expected behavior

Actual behavior

Terminal Output Screenshot(s)

Additional context

Here it's stated that '--without-hashes' should be added to poetry export.
python-poetry/poetry#3472

After taking a more closer look to examples in repository I got my code also working. There were couple of reasons:

  • For some reason my system poetry had fallen back to an ancient 1.1.12 version. Updated to latest poetry 1.5.1 and regenerated poetry.lock.
  • I then created lambda layer and then lambda function (python), which referenced to lambda layer.

Nice and easy once got it working.

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.