-
Notifications
You must be signed in to change notification settings - Fork 73
Add local_file ephemeral resource
#440
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
base: main
Are you sure you want to change the base?
Conversation
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes Have you signed the CLA already but the status is still pending? Recheck it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new ephemeral resource local_file to the local provider, allowing users to create temporary files that are automatically cleaned up when the ephemeral resource lifecycle ends.
Key changes:
- Implements ephemeral resource with content seeding options (content, content_base64, source)
- Adds comprehensive test coverage for different content input methods
- Includes documentation and examples for the new resource
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/provider/ephemeral_local_file.go | Core implementation of the ephemeral local_file resource with Open/Close lifecycle methods |
| internal/provider/ephemeral_local_file_test.go | Comprehensive test suite covering content, base64, and source file scenarios |
| internal/provider/provider.go | Provider registration for ephemeral resources |
| internal/provider/provider_test.go | Test infrastructure updates for ephemeral resource testing |
| docs/ephemeral-resources/file.md | User documentation for the new ephemeral resource |
| templates/ephemeral-resources/file.md.tmpl | Documentation template |
| examples/ephemeral-resources/ephemeral-resource-file.tf | Usage example |
| go.mod | Dependency update for terraform-plugin-log |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // Can't set a default value for ephemeral resources, this is here as a fingers-crossed placeholder. | ||
| // Default: stringdefault.StaticString("0777"), |
Copilot
AI
Aug 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the commented-out code and the todo-style comment. If default values aren't supported for ephemeral resources, the comment explaining the '0777' default in the description is sufficient.
| // Can't set a default value for ephemeral resources, this is here as a fingers-crossed placeholder. | |
| // Default: stringdefault.StaticString("0777"), |
| // Can't set a default value for ephemeral resources, this is here as a fingers-crossed placeholder. | ||
| // Default: stringdefault.StaticString("0777"), |
Copilot
AI
Aug 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the commented-out code and the todo-style comment. If default values aren't supported for ephemeral resources, the comment explaining the '0777' default in the description is sufficient.
| // Can't set a default value for ephemeral resources, this is here as a fingers-crossed placeholder. | |
| // Default: stringdefault.StaticString("0777"), |
|
Would be very useful for my use case. :) Nice job, hopefully gets merged soon. |
|
Been watching this for a while, would be great to see this merged soon. Feels like it would go perfectly with the new tf actions for ansible! ansible/terraform-provider-ansible#146 |
Related Issue
Fixes #373
Description
I've created a new ephemeral resource for
local_filealong with tests to test the different options for data seeding (lifted and shifted from the resource local_file tests with some minor alterations).The only issue I have with this solution is that there's no way to override the pseudo-sensitive nature of ephemeral resources in output, thus making provisioner logs useless if you use an ephemeral value. This is the case even if you're not using 'sensitive' arguments/attributes on the resource, they all obscure output logs.
If this PR is approved I am happy to raise an issue in the main Terraform repository to try and get movement on being able to mark certain arguments safe for output. Case in point: the filename argument on this ephemeral resource should be allowed to be displayed in output logs, be that either with a setting in the schema declaration and/or using the
nonsensitivefunction to mark it as safe.To Be Discussed
I'm undecided if the default permission model should match
local_sensitive_filegiven ephemeral resource values are treated as sensitive in the output context.Note: I'll clean up git commits at a later date.
Rollback Plan
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
No. I have duplicated the file and directory permissions logic from the
local_fileresource.