hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.71k stars 9.55k forks source link

External program backend #23586

Open ncmans opened 4 years ago

ncmans commented 4 years ago

Current Terraform Version

v0.12.16

Use-cases

Create an escape hatch for when an unsupported state backend is desired by the user.

Some scenarios:

Attempted Solutions

Currently, the only available and customizable backend is the http backend. However, it involves running a program separately first and handling of the HTTP protocol. This adds quite a bit of friction compared to say a one line shell script that pipes the state into kubectl to be stored on kubernetes. The identity of the OS user running terraform is also lost which makes running this setup securely a little challenging.

Proposal

I propose to having a backend called exec which like the http backend allows defining custom actions for each state event. The actions would be the shell command that will be run by terraform and state passed onto them in stdin and read from stdout of the called program.

References

pkolyvas commented 4 years ago

Hey @ncmans thanks for the suggestion. :)

We're currently hard at work thinking about how to open up more options for state backends without putting the Terraform team in the critical path of merging, maintenance and ownership.

We don't have an answer yet, but appreciate the effort you've put in here and hope to return in the not-so-distant future with some solutions specifically around when an unsupported state backend is desired by the user.

Stay tuned!