Skip to content

Conversation

@yesdevnull
Copy link

@yesdevnull yesdevnull commented Aug 25, 2025

Related Issue

Fixes #373

Description

I've created a new ephemeral resource for local_file along 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 nonsensitive function to mark it as safe.

To Be Discussed

I'm undecided if the default permission model should match local_sensitive_file given ephemeral resource values are treated as sensitive in the output context.

Note: I'll clean up git commits at a later date.

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

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_file resource.

Copilot AI review requested due to automatic review settings August 25, 2025 13:05
@yesdevnull yesdevnull requested a review from a team as a code owner August 25, 2025 13:05
@hashicorp-cla-app
Copy link

hashicorp-cla-app bot commented Aug 25, 2025

CLA assistant check
All committers have signed the CLA.

@hashicorp-cla-app
Copy link

CLA assistant check

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.

Copy link

Copilot AI left a 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.

Comment on lines +86 to +87
// Can't set a default value for ephemeral resources, this is here as a fingers-crossed placeholder.
// Default: stringdefault.StaticString("0777"),
Copy link

Copilot AI Aug 25, 2025

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.

Suggested change
// Can't set a default value for ephemeral resources, this is here as a fingers-crossed placeholder.
// Default: stringdefault.StaticString("0777"),

Copilot uses AI. Check for mistakes.
Comment on lines +96 to +97
// Can't set a default value for ephemeral resources, this is here as a fingers-crossed placeholder.
// Default: stringdefault.StaticString("0777"),
Copy link

Copilot AI Aug 25, 2025

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.

Suggested change
// Can't set a default value for ephemeral resources, this is here as a fingers-crossed placeholder.
// Default: stringdefault.StaticString("0777"),

Copilot uses AI. Check for mistakes.
@LeCrew163
Copy link

LeCrew163 commented Oct 17, 2025

Would be very useful for my use case. :)

Nice job, hopefully gets merged soon.

@benkelly123
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

new ephemeral resource: local_file

3 participants