terraform-aws-lambda icon indicating copy to clipboard operation
terraform-aws-lambda copied to clipboard

Example package_with_pip_requirements_in_docker fails on Windows 10

Open sebastianmacarescu opened this issue 3 years ago β€’ 8 comments

Description

Trying to deploy the example package_with_pip_requirements_in_docker using Windows fails Error message: zip: Error during zip archive creation Traceback (most recent call last): File ".terraform/modules/terraform-aws-redis-cleanup.redis_cleanup/package.py", line 1137, in build_command bpm.execute(build_plan, zs, query) File ".terraform/modules/terraform-aws-redis-cleanup.redis_cleanup/package.py", line 767, in execute with install_pip_requirements(query, pip_requirements) as rd: File "C:\Python3.7\lib\contextlib.py", line 112, in __enter__ return next(self.gen) File ".terraform/modules/terraform-aws-redis-cleanup.redis_cleanup/package.py", line 888, in install_pip_requirements chown_mask = '{}:{}'.format(os.getuid(), os.getgid()) AttributeError: module 'os' has no attribute 'getuid'

https://github.com/terraform-aws-modules/terraform-aws-lambda/blob/master/package.py#L888

According to this: https://docs.python.org/3.8/library/os.html#os.getgid these 2 functions are available only on Linux. Basically if you run windows you can deploy only lambdas with non native python requirements.

Versions

  • Terraform: v0.13.6
  • Provider(s):
  • provider registry.terraform.io/-/aws v3.36.0
  • provider registry.terraform.io/hashicorp/aws v3.36.0
  • provider registry.terraform.io/hashicorp/external v2.1.0
  • provider registry.terraform.io/hashicorp/local v2.1.0
  • provider registry.terraform.io/hashicorp/null v3.1.0
  • provider registry.terraform.io/hashicorp/random v3.1.0
  • Module: 1.45.0

Reproduction

Just try to deploy like in package_with_pip_requirements_in_docker example from a windows 10 machine

Expected behavior

Use docker to compile python dependencies

Actual behavior

Fails

sebastianmacarescu avatar Apr 09 '21 10:04 sebastianmacarescu

Thanks for the report, it is good to know that it doesn't work on Windows 10. I don't think we have ever run this module on Windows.

PR fixing this is very much welcome!

antonbabenko avatar Apr 09 '21 12:04 antonbabenko

is there any kind of plan to support this?

sassdavid avatar Jul 03 '23 15:07 sassdavid

Same here:

β”‚ Error: local-exec provisioner error
β”‚
β”‚   with module.transform-rolling-continuous-intraday-forecast.module.lambda.null_resource.archive[0],
β”‚   on .terraform\modules\transform-rolling-continuous-intraday-forecast.lambda\package.tf line 67, in resource "null_resource" "archive":
β”‚   67:   provisioner "local-exec" {
β”‚
β”‚ Error running command 'builds\ce92b03d4a0f1bd002555f03392d9f74b290af563877fcbde94e57c2fb7f0639.plan.json': exit status 1. Output: zip: creating
β”‚ 'builds\ce92b03d4a0f1bd002555f03392d9f74b290af563877fcbde94e57c2fb7f0639.zip' archive
β”‚ > docker images '--format={{.ID}}' public.ecr.aws/sam/build-python3.10
β”‚ Installing python requirements: ./../../../../processing/transform-rolling-continuous-intraday-forecast/requirements.txt
β”‚ > mktemp -d terraform-aws-lambda-XXXXXXXX # 'C:\Users\morit\AppData\Local\Temp\terraform-aws-lambda-oblqrfv3'
β”‚ > cd 'C:\Users\morit\AppData\Local\Temp\terraform-aws-lambda-oblqrfv3'
β”‚ zip: Error during zip archive creation
β”‚ Traceback (most recent call last):
β”‚   File "C:\Eigene Daten\Studium\TUM\4. Semester\Masterarbeit\suena\research-and-development\suena\terraform\environments\stage\2-data-fetcher\.terraform\modules\transform-rolling-continuous-intraday-forecast.lambda\package.py", line 1516, in build_command
β”‚     bpm.execute(build_plan, zs, query)
β”‚   File "C:\Eigene Daten\Studium\TUM\4. Semester\Masterarbeit\suena\research-and-development\suena\terraform\environments\stage\2-data-fetcher\.terraform\modules\transform-rolling-continuous-intraday-forecast.lambda\package.py", line 859, in execute
β”‚     with install_pip_requirements(query, pip_requirements, tmp_dir) as rd:
β”‚   File "C:\Users\morit\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 137, in __enter__
β”‚     return next(self.gen)
β”‚            ^^^^^^^^^^^^^^
β”‚   File "C:\Eigene Daten\Studium\TUM\4. Semester\Masterarbeit\suena\research-and-development\suena\terraform\environments\stage\2-data-fetcher\.terraform\modules\transform-rolling-continuous-intraday-forecast.lambda\package.py", line 999, in install_pip_requirements
β”‚     chown_mask = '{}:{}'.format(os.getuid(), os.getgid())
β”‚                                 ^^^^^^^^^
β”‚ AttributeError: module 'os' has no attribute 'getuid'

Macilias avatar Sep 14 '23 15:09 Macilias

I have als this problem. Could you please fix this bug?

Trickels avatar Dec 20 '23 14:12 Trickels

same here unfortunately

EAlf91 avatar Jan 12 '24 06:01 EAlf91

PR fixing this is very much welcome!

Still waiting for the PR :)

antonbabenko avatar Jan 12 '24 11:01 antonbabenko

PS: You should be using WSL

antonbabenko avatar Jan 12 '24 11:01 antonbabenko

terraform for aws lambda on windows is literally broken for 3 years and nobody cares.

I love open source

Akatroj avatar Feb 25 '24 16:02 Akatroj