Skip to content

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

@GaryLiuTelus

Description

@GaryLiuTelus

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions