/terraform-provider-cf

Terraform Cloud Foundry Provider

Primary LanguageGoMozilla Public License 2.0MPL-2.0

Cloud Foundry Terraform Provider Build Status

Overview

This Terraform provider plugin allows you to configure a Cloud Foundry environment declaratively using HCL. The online documentation for the Terraform Cloud Foundry resource is available on the wiki.

Requirements

  • Terraform 0.11.x
  • Go 1.9 (to build the provider plugin)

Building The Provider

Clone repository to: $GOPATH/src/github.com/terraform-providers/terraform-provider-cf

$ mkdir -p $GOPATH/src/github.com/terraform-providers; cd $GOPATH/src/github.com/terraform-providers
$ git clone git@github.com:terraform-providers/terraform-provider-cf

Enter the provider directory and build the provider

$ cd $GOPATH/src/github.com/terraform-providers/terraform-provider-cf
$ make build

Using the provider

Download the release binary and copy it to the $HOME/terraform.d/plugins/<os>_<arch>/terraform-provider-cloudfoundry. For example /home/youruser/terraform.d/plugins/linux_amd64/terraform-provider-cloudfoundry for a Linux environment or /Users/youruser/terraform.d/plugins/darwin_amd64/terraform-provider-cloudfoundry for a MacOS environment.

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine (version 1.8+ is required). You'll also need to correctly setup a GOPATH, as well as adding $GOPATH/bin to your $PATH.

Clone this repository to GOPATH/src/github.com/terraform-providers/terraform-provider-cf as its packaging structure has been defined such that it will be compatible with the Terraform provider plugin framwork in 0.10.x.

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

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

Testing the Provider

To test the provider you will need to run a local PCF Dev instance or launch it in AWS via the scripts/pcfdev-up.sh. Once the instance is running you will need to export the following environment variables.

export CF_API_URL=https://api.local.pcfdev.io
export CF_USER=admin
export CF_PASSWORD=admin
export CF_UAA_CLIENT_ID=admin
export CF_UAA_CLIENT_SECRET=admin-client-secret
export CF_CA_CERT=""
export CF_SKIP_SSL_VALIDATION=true

You can export the following environment variables to enable detail debug logs.

export CF_DEBUG=true
export CF_TRACE=debug.log

In order to run the tests locally, run.

cd cloudfoundry
TF_ACC=1 go test -v -timeout 120m .

To run the tests in AWS first launch PCFDev in AWS via scripts/pcfdev-up.sh, and then run.

make testacc

Acceptance tests are run against a PCF Dev instance in AWS before a release is created. Any other testing should be done using a local PCF Dev instance.

$ make testacc

Terraform Links