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

Empty requirements.txt failure #467

Closed Fran-Rg closed 11 months ago

Fran-Rg commented 1 year ago

Description

When using an empty requirements.txt the module fails with the following stacktracke:

Error running command
'builds/feb6da9d650d6b2c26aca117bff0badb1b3ae2a460d60ecc6efd621cfb99ca49.plan.json':
exit status 1. Output: Traceback (most recent call last):
  File ".terraform/modules/LAMBDA_NAME/package.py", line 1389, in <module>
    main()
  File ".terraform/modules/LAMBDA_NAME/package.py", line 1385, in main
    exit(args.command(args))
  File ".terraform/modules/LAMBDA_NAME/package.py", line 1277, in build_command
    bpm.execute(build_plan, zs, query)
  File ".terraform/modules/LAMBDA_NAME/package.py", line 318, in __exit__
    self.close()
  File ".terraform/modules/LAMBDA_NAME/package.py", line 308, in close
    os.replace(self._tmp_filename, self.filename)
FileNotFoundError: [Errno 2] No such file or directory:
'builds/feb6da9d650d6b2c26aca117bff0badb1b3ae2a460d60ecc6efd621cfb99ca49.zip.tmp'
->
'builds/feb6da9d650d6b2c26aca117bff0badb1b3ae2a460d60ecc6efd621cfb99ca49.zip'

I believe the problem is due to the zip not being created since it doesn't have anything to pack. A test on requirements.txt size > 0 would prevent that.

Versions

Reproduction Code [Required]

Steps to reproduce the behavior:

Create a python lambda with the source_path directory containing an empty requirements.txt file

Expected behavior

Considered to not have a requirements.txt

Actual behavior

  1. pip tries to install
  2. nothing is created
  3. no zip is created
  4. the pipeline fails
hsdp-smulford commented 1 year ago

+1

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

github-actions[bot] commented 11 months ago

This issue was automatically closed because of stale in 10 days

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