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 656 forks source link

Build pip requirements.txt to specific runtime (cross macos-linux/architecture compilation) #459

Closed caioquirino closed 6 months ago

caioquirino commented 1 year ago

Is your request related to a problem? Please describe.

I am having to use docker to build a lambda layer from a pip requirements.txt file, but since I am doing it locally from a macbook, the binaries are added for darwin architecture.

It would be great if I can force it to use linux/amd64 (manylinux) or something that is compatible with AWS Lambda when building it locally

Describe the solution you'd like.

It would be great if together with pip_requirements in the source_path list, I could use something like platform="linux/amd64" or even following the pypa manylinux standards as platform="manylinux2014_x86_64".

Or as another option, to use the compatible_runtimes and architectures or runtime fields already existing in the module.

Describe alternatives you've considered.

If I can fix the issue https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/458 that would be another alternative

Additional context

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

caioquirino commented 1 year ago

Up

github-actions[bot] commented 11 months 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

caioquirino commented 10 months ago

Up...

jcopps commented 10 months ago

Up..

atyndall commented 10 months ago

Ran into this, would be very useful

jcopps commented 10 months ago

Two workaround options:

@atyndall , @caioquirino

  1. One may try this: https://stackoverflow.com/a/74729370/3195195
  2. Use docker with pip requirements.txt. In this case, the docker can be set with the right platform architecture and the build takes care of itself.
atyndall commented 10 months ago

Thanks @jcopps. It would be great if the module could set the --platform manylinux2014_x86_64 itself.

jcopps commented 10 months ago

Agreed. But the docker support was added for a reason like these I presume.

caioquirino commented 10 months ago

@jcopps it exists, but it is not working for my use case (cross compiling mac-os m1 to linux x64): https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/458

jcopps commented 10 months ago

@caioquirino Did you try specifying the image of the docker from docker registry to be of linux x64.

caioquirino commented 10 months ago

@jcopps you can find a lot of information about what is happening in the #458 issue :) TLDR: Yes

userhas404d commented 9 months ago

I ran into this recently as a result of this issue. I was able to cheese it locally by manually cramming in the pip options required here but needed both --platform and --only-binary, as a result my recommendation for this issue (and solution) would be to allow the input of an arbitrary number of additional pip options

github-actions[bot] commented 8 months 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

atyndall commented 8 months ago

Not stale

github-actions[bot] commented 7 months 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

atyndall commented 7 months ago

Not stale

github-actions[bot] commented 6 months 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

github-actions[bot] commented 6 months ago

This issue was automatically closed because of stale in 10 days

github-actions[bot] commented 5 months 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.