Terraform GitOps Provider
DEPRECATION NOTICE
Tyler is moving away from supporting this repository. We will deprecate and archive it on August 1, 2024, removing it from public access. If you have forked this repo, please feel free to detach your fork and continue development on your own.
Cheers.
Tyler Technologies
Synopsis
A Terraform cloud optimized plugin to manage files in git repositories.
Note: While this provider is optimized for terraform cloud/enterprise, it will still work excellently for terraform open source.
This allows you to export terraform managed state into other systems which are controlled
by git repositories - for example commit server IPs to DNS config repositories,
or write out hiera data into your puppet configuration.
This provider was originally forked from https://github.com/joestump/terraform-provider-gitfile. The provider has been rewritten from the ground up to support functionality requirements for a full gitops workflow, and is optimized to work with Terraform Cloud.
Example:
provider "gitops" {
repo_url = "https://myverisoncontrolprovider.com/my/repo"
branch = "master"
path = "tmp.mycheckoutdestination"
}
resource "gitops_checkout" "test_checkout" {}
resource "gitops_file" "test_file" {
checkout = gitops_checkout.test_checkout.id
path = "terraform"
contents = "Terraform making commits"
}
resource "gitops_symlink" "test_symlink" {
checkout = gitops_checkout.test.id
path = "terraform"
target = "/etc/passwd"
}
resource "gitops_commit" "test_commit" {
commit_message = "Created by terraform gitops_commit"
handles = [gitops_file.test_file.id, gitops_file.test_symlink.id]
}
Resources
gitops_checkout
Checks out a git repository onto your local filesystem from within a terraform provider.
This is mostly used to ensure that a checkout is present, before using the gitops_commit
resource to commit some Terraform generated data.
Inputs:
- retry_count - The number of git checkout retries
- retry_interval - The number of seconds between git checkout retries
Outputs:
- path - The file path on filesystem where the repository has been checked out
- repo - The repository url that was checked out
- branch - The branch being checked out
- head - The git head value
gitops_file
Creates a file within a git repository with some content from terraform
Inputs:
- checkout - The ID of the checkout resource the files are associated with
- path - The path within the checkout to create the file at
- contents - The contents of the file
Outputs:
- id - The id of the created file. This is usually passed to gitops_commit
gitops_symlink
Creates a symlink within a git repository from terraform
Inputs:
- checkout - The ID of the checkout resource the files are associated with
- path - The path within the checkout to create the symlink at
- target - The place the symlink should point to. Can be an absolute or relative path
Outputs:
- id - The id of the created symlink. This is usually passed to gitops_commit
gitops_commit
Makes a git commit of a set of gitops_commit and gitops_file resources in a git
repository, and pushes it to origin.
Note that even if the a file with the same contents Terraform creates already exists,
Terraform will create an empty commit with the specified commit message.
Inputs:
- commit_message - The commit message to use for the commit
- handles - An array of ids from gitops_file or gitops_symlink resources which should be included in this commit
- retry_count - The number of git commit retries
- retry_interval - The number of seconds between git commit retries
Outputs:
- commit_message - The commit message for the commit that will be made
License
Apache2 - See the included LICENSE file for more details.