terraform-aws-modules/terraform-aws-lambda

Empty requirements.txt failure

Fran-Rg opened this issue · 4 comments

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.

  • [y] ✋ I have searched the open/closed issues and my issue is not listed.

Versions

  • Module version [Required]:

  • Terraform version:
    1.3.7

  • Provider version(s):

  • provider registry.terraform.io/hashicorp/aws v4.57.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

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

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

This issue was automatically closed because of stale in 10 days

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.