terraform-provider-archive icon indicating copy to clipboard operation
terraform-provider-archive copied to clipboard

Zip file created by terraform archive_file cannot be properly read by python

Open GaryLiuTelus opened this issue 2 years ago • 0 comments

Terraform CLI and Provider Versions

Terraform 0.14.9

Terraform Configuration

The code is as below

data "archive_file" "utilities_zip" {
    type = "zip"
    source_dir = "./source/utilities"
    output_path = "/tmp/utilities.zip"
}

The folder structure of utilities:

/source/utilities --dsa/ ----test.py ----xxx/ -------abc.py



### Expected Behavior

The following python code should go through: 

```python
import sys
sys.path.insert(1, "/tmp/utilities.zip")

from dsa import test

Actual Behavior

Got below error:

ModuleNotFoundError: No Module named 'dsa'

If unzip the zip file and rezip using 7-zip, or zip the folder using zip -r /tmp/utilities.zip dsa command, the above python code can run without any issues.

Steps to Reproduce

  1. create a folder containing some python file
  2. zip folder with terraform
  3. terraform apply
  4. try to refer and import python file from zip file.

How much impact is this issue causing?

High

Logs

No response

Additional Information

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

GaryLiuTelus avatar Dec 22 '22 22:12 GaryLiuTelus