Skip to content

Terraform module to create zip archives containing python package with all its dependencies.

License

Notifications You must be signed in to change notification settings

Bubo-AI/terraform-python-packager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-python-packager

Terraform module to create an archive for a python package with its dependencies. A possible use case is to deploy a lambda function to AWS with custom dependencies.

Example usage

module python_packager {
  source  = "github.com/Bubo-AI/terraform-python-packager?ref=v0.1.0"
  src_dir = "/path/to/python/package"
}

Fully working example for deploying a custom python module to AWS Lambda function can be found inside the example folder.

Inputs

Variable Description Type Default
src_dir Path to python package directory without trailing /. string N/A
requirements_path* Path to requirements.txt. Required if src_dir does not contain it. string src_dir/requirements.txt
package_name* Path to output archive file. string pkg.zip

* optional variable

Outputs

Name Description
package_path The path of zip archive.
package_hash The base64-encoded SHA256 checksum of the archive file.

Requirements

This module was tested against Terraform v1.1.3. It does not use any Terraform providers, and does not declare any Terraform resources. It is compatible with *nix systems.

Limitations

This module assumes archived package will run on 64-bit linux environment and required python version is 3.9.

If you have different requirements, please adjust the parameters of pip from the last local-exec provider inside the main.tf.

Note regarding symbolic links

Due to a bug, this module does not currently create proper zip archives when the source includes symbolic links (also known as "symlinks"). Please see Terraform Archive Issue #6 for more details and workaround options.