Skip to content
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

Add option for failing if local file already exists #150

Open
1 task done
baolsen opened this issue Oct 21, 2022 · 0 comments
Open
1 task done

Add option for failing if local file already exists #150

baolsen opened this issue Oct 21, 2022 · 0 comments

Comments

@baolsen
Copy link

baolsen commented Oct 21, 2022

Terraform CLI and Provider Versions

N/A

Use Cases or Problem Statement

Local file is useful for unit testing scenarios.

Sometimes third parties want to test failure conditions with tests, such as what happens when Terraform apply is partially successful.

See for example this issue and associated PR with comments:
cloud-custodian/pytest-terraform#59

With that PR it would have been great to be able to run TF destroy on the local file and ensure that partially applied resources are cleaned up by testing for the existence of local file after the test has run.

However with the current "silent overwrite" behaviour there is no way to force local file to fail.

I can also imagine a use case where in a complex repo, local file silently overwriting other instances of itself would be unexpected behaviour for the user. It would be better to allow them a way to ensure that a conflict is made visible.

Proposal

A simple optional variable could be added for overriding the default behaviour.

Perhaps support multiple file modes, like overwrite (default), append, error. Though for this use case, only "error" is desirable.

While the order of Terraform apply is usually non-deterministic, the depends_on property can be used to control ordering. So "append" is foreseeably something that could make sense to someone in future.

How much impact is this issue causing?

Low

Additional Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant