-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
archive_file data source gets created during "terraform plan" vs "terraform apply" and also is not deleted during destroy #218
Comments
Hi @jeffscottlevine 👋 It sounds like you might need to use the archive_file resource rather than the data source in this instance. Could you try using the resource and see if that behaves in the way that you are expecting? |
According to this page, the archive_file resource is deprecated and that we should use the data source. |
Although the archive_file resource is marked as deprecated, there are currently no plans to remove it. |
Can you remove the deprecation note? The datasource is no replacement for the archive_file resource. |
I very much agree with @Console32, the data source is no replacement for the archive_file resource. One use case is when I need something to happen before the zip is created. When the zip is created during plan this is rather difficult to do. |
@bendbennett would it be possible to remove the deprecation note? |
Would it be possible to remove deprecation note? There strong use case for it. In our case when we work with lambdas in AWS. |
We will discuss removal of the deprecation note from the archive resource within the team and provide feedback once a conclusion has been reached. |
Can you explain the difference between the resource and the data source? The docs do not explain what the difference is. It seems that the resource creates the archive during apply, but the data source creates it during plan. This resolved the problem I was having, so I hope that the resource isn't actually deprecated. It's confusing to suggest to use the resource if it says right at the top of the docs and during plan that the resource is deprecated and to use the data source instead. |
It looks as if the deprecation is proceeding, as I've just encountered this message in
|
Any updates on this? I'm currently using the |
Given the immense traction this issue has and the fact that nothing changed, it's likely that the behavior will never change. Can you just give us best practices to how we deal with this ? I am using bitbucket and my plan and apply are different steps. EDIT: In my case, the solution was simple and I think that it is the generic solution for CI/CD pipelines. Add your zipped file name as an artifact of your planning step. Here is my example code for bitbucket : pipelines:
branches:
master:
- step:
name: Terraform plan
artifacts:
- terraform/main/.out/plan
- terraform/main/.out/zipped-source.zip
script:
- sh ./.bin/deploy.sh plan
condition:
changesets:
includePaths:
- "terraform/main/**" |
I use data.archive_file to and this causes a problem when dir for zip is deleted and will be recreated after terraform apply because it's a lambda layer. So for now I plan to change to resource archive_file or may be some one can advise better solution. |
- from what i gathered from the git history, this resource was introduced in `v2.3.0` in a deprecated state - discussion with the community involving @bendbennett resulted in the consideration of this deprecation being removed (see: hashicorp#218) - since `v2.x` there has been a strong focus on keeping this provider limited to the `data` source, so some of this proposed change is taking a best guess at what makes sense while trying not to depart from the overall approach - i acknowledge that this appears to be in some ways orthogonal to the goal of the project, but there has been little movement in regards to this widely-requested feature (understandably so, based on reasons mentioned above). - there are cases, primarily in a remote build server context, where the design decisions/limitations of the `data` source makes the adoption and usage of this provider much more challenging. this change is proposed as a stop-gap until a larger focus is able to put on this project by the primary contributing team
I am also facing same issue where the terraform plan is successful but apply fails. Is there any concrete response to resolve this long pending issue? |
- from what i gathered from the git history, this resource was introduced in `v2.3.0` in a deprecated state - discussion with the community involving @bendbennett resulted in the consideration of this deprecation being removed (see: hashicorp#218) - since `v2.x` there has been a strong focus on keeping this provider limited to the `data` source, so some of this proposed change is taking a best guess at what makes sense while trying not to depart from the overall approach - i acknowledge that this appears to be in some ways orthogonal to the goal of the project, but there has been little movement in regards to this widely-requested feature (understandably so, based on reasons mentioned above). - there are cases, primarily in a remote build server context, where the design decisions/limitations of the `data` source makes the adoption and usage of this provider much more challenging. this change is proposed as a stop-gap until a larger focus is able to put on this project by the primary contributing team
@bendbennett and the rest of the contributing team, please consider this pull request thanks! |
I wanted to provide my use case. I depend on Terraform outputting the source_code_hash for AWS Lambdas during Terraform plans. At work, we use these Terraform plans for our deployment approval processes and it’s crucial that the SHA256 Base64 encoded checksum of Lambda packages be present within Terraform plan output. This checksum within an approved Terraform plan is the easiest way to actually validate that the Lambda package currently deployed in AWS matches the approved Terraform plans. |
Yes it will work for very few use case like yours. In general, the replacement is not working.
|
Hi everyone 👋🏾
|
- from what i gathered from the git history, this resource was introduced in `v2.3.0` in a deprecated state - discussion with the community involving @bendbennett resulted in the consideration of this deprecation being removed (see: hashicorp#218) - since `v2.x` there has been a strong focus on keeping this provider limited to the `data` source, so some of this proposed change is taking a best guess at what makes sense while trying not to depart from the overall approach - i acknowledge that this appears to be in some ways orthogonal to the goal of the project, but there has been little movement in regards to this widely-requested feature (understandably so, based on reasons mentioned above). - there are cases, primarily in a remote build server context, where the design decisions/limitations of the `data` source makes the adoption and usage of this provider much more challenging. this change is proposed as a stop-gap until a larger focus is able to put on this project by the primary contributing team
* feat: remove `archive_file` resource deprecation notice - from what i gathered from the git history, this resource was introduced in `v2.3.0` in a deprecated state - discussion with the community involving @bendbennett resulted in the consideration of this deprecation being removed (see: #218) - since `v2.x` there has been a strong focus on keeping this provider limited to the `data` source, so some of this proposed change is taking a best guess at what makes sense while trying not to depart from the overall approach - i acknowledge that this appears to be in some ways orthogonal to the goal of the project, but there has been little movement in regards to this widely-requested feature (understandably so, based on reasons mentioned above). - there are cases, primarily in a remote build server context, where the design decisions/limitations of the `data` source makes the adoption and usage of this provider much more challenging. this change is proposed as a stop-gap until a larger focus is able to put on this project by the primary contributing team * docs: notes for `archive_file` `resource` versus `data` source * docs: changie release notes for #218 * docs: changie formatting Co-authored-by: Selena Goods <[email protected]> --------- Co-authored-by: Selena Goods <[email protected]>
v2.7.0 has just been released with the removal of the |
Terraform CLI and Provider Versions
Terraform v1.4.6
on linux_amd64
Terraform Configuration
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
The text was updated successfully, but these errors were encountered: