Example Terraform project for configuring PactFlow.
The Terraform definitions automate configuration of:
- Creation of user accounts and teams.
- Creation of Pacticipants.
- Configuration of Webhooks.
For more information about the Pact Broker Terraform Provider, check out the documentation on the Pact website or the Terraform Registry.
-
Create a free account on https://pactflow.io
-
Install Terraform with tfenv. Terraform version will be read from .terraform-version file.
brew install tfenv
tfenv install
- Create a Pactflow read/write API token and export environment variables:
export TF_VAR_pact_host=https://<your-account-name>.pactflow.io
export TF_VAR_pact_access_token=<your-read-write-api-token>
export TF_VAR_default_user_name=<your-first-and-last-name> # Name with which you registered on pactflow.io
export TF_VAR_default_user_email=<your-email>
- Init Terraform modules
terraform init
-
We'll have to import default user and team to Terraform resources because Pact Terraform provider doesn't support data sources.
-
Import default user to Terraform state. You can find your user
uuid
through the HAL browser withGET /admin/users
at https://your-account-name.pactflow.io/hal-browser/browser.html#https://your-account-name.pactflow.io/admin/users. Read more about importingpact_user
resource at registry.terraform.io.
terraform import pact_user.default <your-user-uuid>
- Import default team to Terraform state.
Your can find the default team
uuid
through the HAL browser withGET /admin/teams
at https://your-account-name.pactflow.io/hal-browser/browser.html#https://your-account-name.pactflow.io/admin/teams. Read more about importingpact_team
resource at registry.terraform.io.
terraform import pact_team.default <default-team-uuid>
- Run Terraform apply to create the rest of the resources
terraform apply
- Lint
brew install tflint
brew install tfsec
tflint
tfsec