Workflow examples

Workflow examples demonstrate how to use Terraprep in different scenarios.

Can I create a remote backend without going to a cloud platform console/portal?

Yes, you can. Terraprep enables you to swiftly create a remote backend without any manual steps. For instance, if you wish to create a remote GCS storage bucket for use with Terraprep, follow the steps below:

We’re using gcp as the backend in this example.

  1. Initialise terraprep configuration.
terraprep init
  1. Initialize the GCP backend configuration and complete the initialization by following the prompts.
terraprep gcp init
  1. Create the GCP storage account remote backend from the config.
terraprep gcp create backend --from-config

At this point, you should be able to see your newly created remote backend.


If I can create a remote backend using a cloud platform CLI (az, gcloud, or aws), why would I use Terraprep?

Terraprep not only facilitates the creation of remote backends, but it also aids in rapidly testing existing Terraform templates with the created backend. Furthermore, Terraprep is a single binary capable of setting up multiple backend types as required. Here’s an example of how you can achieve that, using postgres as the backend.

  1. Initialise terraprep configuration.
terraprep init
  1. Initialize the Postgres backend configuration and complete the initialization by following the prompt.
terraprep postgres init
  1. Create the Postgres remote backend from the config.
terraprep postgres create backend --from-config
  1. Create Terraform templates and note the creation of a Postgres template folder on your Desktop.
terraprep postgres create terraform --output-folder ~/Desktop/
  1. Place your existing Terraform files in that folder and use the backend config generated by Terraprep to initialize Terraform with your newly created remote backend.
terraform init

Can I create a backend from the command-line without an interactive prompt?

Yes, Terraprep allows users to create remote backends without interactive prompts, making it possible to supply in-line values or environment variables where appropriate. The example below illustrates Terraprep’s usage without interactive prompts for a GCP backend:

  1. Initialize the Terraprep configuration.
terraprep init
  1. Review the Requirements for the gcp backend and ensure they are met.

  2. Create the Google Cloud Storage remote backend using the command below. Use noorg (as shown below) or your GCP Org ID for the --organisation flag.

terraprep gcp create backend \
--organisation "noorg" \
--project "myProject" \
--region "europe-west2" \
--bucket "terraprep"