TransWikia.com

Dedicated/Separate Git Repo as Terraform Remote Backend

DevOps Asked by Haneef Ibn Ahmad on October 10, 2020

I see that there are multiple options for Backends, however git isn’t one of them.

I believe git can be used as a backend for tfstate, in the below steps:

  1. Create a dedicated git repo
  2. Commit the tfstate files in a specified directory and branch. Only fetch the required files, rather than the whole repo, as this repo could be used to store multiple tfstate files on different directories.
  3. For locking and unlocking:
    Method 1 (git LFS): use ‘git lfs lock

Method 2 (git – where lfs isn’t possible): Use another file suffixed with .lock, which should contain the lock state.

Is there any plan for Terraform to release git as a backend?

I’ve also thought of ways to use the HTTP backend to upload to a git, no luck yet.

Thoughts on how this can be achieved?

There’s already a Github/Gitlab/Bitbucket provider.

Thanks,

Note: Also asked in the Terraform Discuss

One Answer

Using git for terraform remote state management is an interesting, but non-standard implementation. Storing binary / large files in git, integrating a locking system and a few other concerns come to mind. Using s3, Buckets or other storage options provide the multiple statefile management (versions in buckets, folders in buckets or terraform folder structure / workspaces) and other functionality you mentioned.

If you would like to pursue using git for remote state management, check out the community project terraform-backend-git. There is also a good discussion around it in the terraform issues section: https://github.com/hashicorp/terraform/issues/16616.

If you attempt to use the tool from the community, it would be great to hear about your experience. Good luck!

Answered by George on October 10, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP