Skip to content

archive_file data source gets created during "terraform plan" vs "terraform apply" and also is not deleted during destroy #218

@ghost

Description

Terraform CLI and Provider Versions

Terraform v1.4.6
on linux_amd64

  • provider registry.terraform.io/hashicorp/archive v2.3.0
  • provider registry.terraform.io/hashicorp/google v4.66.0
  • provider registry.terraform.io/hashicorp/local v2.4.0
  • provider registry.terraform.io/hashicorp/random v3.5.1

Terraform Configuration

terraform {
  required_providers {
    archive = {
      version = ">= 2.3.0"
    }
}

data "archive_file" "source_files" {
  type        = "zip"
  output_path = "${path.module}/src.zip"

  source {
    content  = file("${path.module}/requirements.txt")
    filename = "requirements.txt"
  }

  source {
    content  = file("${path.module}/main.py")
    filename = "main.py"
  }
}

Expected Behavior

I would expect that:

(1) The archive file would not be created during "terraform plan"
(2) The archive file would be created during "terraform apply"
(3) The archive file would be deleted during "terraform destroy"

Actual Behavior

(1) The archive file is created during "terraform plan"
(2) The archive file is not destroyed during "terraform destroy"

Steps to Reproduce

Terraform command: 1.4.6
archive provider: 2.3.0

To replicate

(1) Create some source files. I am using main.py and requirements.txt but they can be any files.

(2) Create a tf file that contains the following.

terraform {
required_providers {
archive = {
version = ">= 2.3.0"
}
}

data "archive_file" "source_files" {
type = "zip"
output_path = "${path.module}/src.zip"

source {
content = file("${path.module}/requirements.txt")
filename = "requirements.txt"
}

source {
content = file("${path.module}/main.py")
filename = "main.py"
}
}

(3) Run "terraform plan --out=plan.out"

You will see that src.zip has been created during "terraform plan" rather than waiting for "terraform apply"

(4) terraform apply

(5) terraform destroy

src.zip continues to exist

How much impact is this issue causing?

Low

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