Skip to content

Instantly share code, notes, and snippets.

@gravesm
Created July 31, 2020 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gravesm/d627a62e2199996deb9dcd7c5a0ab0de to your computer and use it in GitHub Desktop.
Save gravesm/d627a62e2199996deb9dcd7c5a0ab0de to your computer and use it in GitHub Desktop.
TF remote apply workflows

Notes

  • Does not appear possible to run an apply locally

Open Questions

  • Keep using a mono-repo or switch to one repo per service?
  • Should stage and prod both deploy from master or should there be a long running prod branch?

Workspace Configuration

Two workspaces are created per app and named <app_name>-stage and <app_name>-prod

Workflow

  1. Make changes locally
  2. (optional) Run terraform plan locally
  3. Commit/push changes
  4. Create PR and wait for TF Cloud to run a plan
  5. Get PR approval and merge into master
  6. Approve the plan in TF cloud for stage, then prod

Support for Global Module

Since TF Cloud doesn't really use workspaces in the local sense, this is easy. We only create a single TF Cloud workspace for any configurations that should be global.

Sharing State Between Workspaces

Pull from the remote state of the desired workspace. Set up a run trigger in TF Cloud. When a successful apply happens in the source workspace TF Cloud will run a plan in the dependent workspace.

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