Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip install --no-deps in commands does not work #557

Closed
stamak opened this issue Apr 3, 2024 · 3 comments · Fixed by #560
Closed

pip install --no-deps in commands does not work #557

stamak opened this issue Apr 3, 2024 · 3 comments · Fixed by #560
Assignees

Comments

@stamak
Copy link

stamak commented Apr 3, 2024

Description

Trying to put numpy into separate layer with --no-deps in commands but it does not work

https://repost.aws/knowledge-center/lambda-import-module-error-python

Versions

  • Module version [Required]:
    registry.terraform.io/terraform-aws-modules/lambda/aws 7.2.5
  • Terraform version:
Terraform v1.4.6
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v5.38.0
+ provider registry.terraform.io/hashicorp/external v2.3.3
+ provider registry.terraform.io/hashicorp/local v2.5.1
+ provider registry.terraform.io/hashicorp/null v3.2.2

Reproduction Code [Required]

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

  create_function = false
  create_layer    = true

  layer_name               = "lambda-layer-numpy"
  compatible_runtimes      = ["python3.10"]
  compatible_architectures = ["arm64"]

  source_path = [
    {
      path = "${path.module}/layer"
      commands = [
        "cd `mktemp -d`",
        "pip3 install --target=. --no-deps numpy",
        ":zip . python/"
      ]
    }
  ]
}

Steps to reproduce the behavior:

Expected behavior

Executed commands

Actual behavior

Uploaded file must be a non-empty zip

Terminal Output Screenshot(s)

module.lambda_layer_numpy.null_resource.archive[0]: Creating...
module.lambda_layer_numpy.null_resource.archive[0]: Provisioning with 'local-exec'...
module.lambda_layer_numpy.null_resource.archive[0] (local-exec): Executing: ["python3" ".terraform/modules/lambda_layer_numpy/package.py" "build" "--timestamp" "1712169865535970000" "builds/5f862cceeb76a95db37612cfb4237795039a66e098c11a6a40ff504
9e69ba092.plan.json"]
module.lambda_layer_numpy.null_resource.archive[0] (local-exec): zip: creating 'builds/5f862cceeb76a95db37612cfb4237795
039a66e098c11a6a40ff5049e69ba092.zip' archive
module.lambda_layer_numpy.null_resource.archive[0] (local-exec): exit_code: 0
module.lambda_layer_numpy.null_resource.archive[0] (local-exec): zip: adding content of directory: .terraform/modules/lambda_layer_numpy.null_resource.archive[0] (local-exec): Created: builds/5f862cceeb76a95db37612cfb4237795039a66e098c11a6a40ff5049e69ba092.zip
module.lambda_layer_numpy.null_resource.archive[0]: Creation complete after 2s [id=4644124653626418376]
...
│ Error: creating lambda layer: InvalidParameterValueException: Uploaded file must be a non-empty zip
│ {
│   RespMetadata: {
│     StatusCode: 400,
│     RequestID: "03fa6a11-2e52-4300-a7db-c07eedee01e8"
│   },
│   Message_: "Uploaded file must be a non-empty zip",
│   Type: "User"
│ }
@pdecat
Copy link
Contributor

pdecat commented Apr 10, 2024

The main issue here seems that the working dir of the shell in which commands are executed is changed by "cd `mktemp -d`", which was a supported use case before #534.

@pdecat pdecat self-assigned this Apr 10, 2024
@antonbabenko
Copy link
Member

This issue has been resolved in version 7.2.6 🎉

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants