-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Introduce a resource that enumerates files inside a zip archive #30098
Comments
Thanks for translating your feature request from Discuss! If there are any updates we will update this issue. |
Thanks indeed for bringing this over to be a feature request! I do want to be up front here and note that the team which works in this repository is not a team that typically develops or maintains individual Terraform providers, but since this is entirely new functionality where it's not really clear which provider it might belong to or whether it ought to be an entirely new provider that doesn't exist yet, this does seem like a reasonable place to keep the use-case recorded for now. One possible candidate answer would be to add this to the |
No worries, I'm usually on the other side of the feature request, so I always take the time to write one as I'd like to receive it. I have no issue with the triage process, it's perfectly understandable. I mean, if in the end this is accepted, I'm happy with it, wherever it may be placed. |
Looking at this issue from the AWS provider, I see that the |
Assuming you're talking about I don't think we'd consider adding any built-in functions to Terraform which interact with specific archive file formats, because that's a pretty heavy set of new code to introduce for a relatively specialized need. However, if we implement something to address #25940 in future then that would in principle allow a provider plugin to offer a function like that, which would be essentially the same as a data source but with a subjectively "lighter" call syntax. We do have a high-level initial design proposal for that internally but haven't yet been able to prioritize a detailed exploration of it. It is interesting to think about what effect the addition of a means to enumerate zip file contents would have on the design of a module like |
FWIW, Terraform v1.8 has now introduced the possibility for providers to contribute new functions to the Terraform language, and so it's now technically possible for someone to write a utility provider that includes functions for working with zip files. |
Current Terraform Version
Use-cases
My CI/CD system is bundling various parts of the AWS application into zip archives.
When this is meant for a lambda function, I can simply use that zip file as the source for the lambda
But I also need to place the content of some zip files into an S3 bucket to serve as the source for an API gateway integration.
It would thus be nice to be able to use a construct that serves as the source for a
for-each
statement applied to aaws_s3_bucket_object
resourceAttempted Solutions
If the zip archive has its files already extracted locally, I can achieve the
for-each
part just fine by using thehashicorp/dir/template
module like this:Note that I don't really need the "template" part, I just use the enumeration of files here.
Extracting the files can be done beforehand with a
null_resource
and an associatedlocal-exec
provisioner that would retrieve the zip file and then unzip it at the appropriate locationProposal
Using a
local-exec
provisioner means the terraform configuration depends on operating system particularities where it runs, which makes it less portable.The documentation itself warns against such a use case:
This is why I believe it would be nice to have a module that would enumerate the content of a zip file, thus allowing to have everything defined in Terraform without relying on external scripts that depend on the operating system where terraform is run.
References
https://discuss.hashicorp.com/t/enumerate-zip-file-content/32785/3
The text was updated successfully, but these errors were encountered: