Skip to content

garry-jeromson/terraform

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pact Broker - Terraform Provider

Terraform Provider for Pact Broker and Pactflow.

Build Status Coverage Status Go Report Card GoDoc slack

Introduction

Example:

variable "token" {
  type = string
}

provider "pact" {
  # For the OSS Broker
  # host = "http://localhost"
  # basic_auth_username = "pact_broker"
  # basic_auth_password = "pact_broker"

  # For a Pactflow Broker
  host = "https://mybroker.pact.dius.com.au"
  access_token = var.token
}

# Create a Pacticipant
resource "pact_pacticipant" "billy" {
  name = "billy"
  repository_url = "github.com/foo/billy"
}

# Create a Pacticipant
resource "pact_pacticipant" "sally" {
  name = "sally"
  repository_url = "github.com/foo/sally"
}

resource "pact_webhook" "billy_changed" {
  description = "new description"
  webhook_provider = {
    name = "billy"
  }
  webhook_consumer = {
    name = "sally"
  }
  request {
    url = "https://foo.com/some/endpoint"
    method = "POST"
    username = "test"
    password = "password"
    headers = {
      "X-Content-Type" = "application/json"
    }
    body = <<EOF
{
  "pact": "$${pactbroker.pactUrl}"
}
EOF
  }

  events = ["contract_content_changed", "contract_published"]
  depends_on = [pact_pacticipant.billy, pact_pacticipant.sally]
}

resource "pact_secret" "some_jenkins_token" {
  name = "JenkinsPactSecret"
  description = "Jenkins token for Pactflow"
  value = "my super secret value"
}

Installing

Download the latest release and install into your Terraform plugin directory.

Linux or Mac OSX

Run the following to have the provider installed for you automatically:

curl -fsSL https://raw.githubusercontent.com/pactflow/terraform/master/scripts/install.sh | bash

Windows

Dowload the plugin to %APPDATA%\terraform.d\plugins.

Installation notes

To use a released provider in your Terraform environment, run terraform init and Terraform will automatically install the provider. To specify a particular provider version when installing released providers, see the Terraform documentation on provider versioning.

To instead use a custom-built provider in your Terraform environment (e.g. the provider binary from the build instructions above), follow the instructions to install it as a plugin. After placing the custom-built provider into your plugins directory, run terraform init to initialize it.

For either installation method, documentation about the provider specific configuration options can be found on the provider's website.

Using the plugin

Plugin Type Platform Support Description
Pact Provider Pact Broker + Pactflow Configures a target Pact Broker (such as a pactflow.io account)
Pacticipant Resource Pact Broker + Pactflow Create applications (known as Pacticipants)
Webhook Resource Pact Broker + Pactflow Configures a webhook to trigger on certain platform events
Secret Resource Pactflow Create an encrypted secret for use in Webhooks
API Token Resource Pactflow Manage Pactflow API Tokens

See our Docs folder for all plugins.

Developing

Requirements

  • Terraform 0.10+
  • Go 1.13 (to build the provider plugin)

Building locally

Note: This project uses Go Modules making it safe to work with it outside of your existing GOPATH. The instructions that follow assume a directory in your home directory outside of the standard GOPATH (e.g. $HOME/development/terraform-providers/).

To compile the provider, run make build. This will build the provider and put the provider binary in the ./bin directory.

$ make build
...
$ $GOPATH/bin/terraform-provider-aws
...

Roadmap

Plan for the next few months:

  • Pacticipants
  • Webhooks
  • Secrets (Pactflow only)
  • API Tokens (Pactflow only)
  • Better error messages for HTTP / runtime failures
  • Proper acceptance tests
  • Better code coverage
  • Extract Client into separate SDK package
  • Publish 1.0.0

Want to see something else here? Have you say on our Pact Feature Request board.

About

Terraform provider for Pact Broker (and Pactflow)

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 84.5%
  • Shell 5.4%
  • Makefile 5.3%
  • HCL 4.8%