Skip to content

panther-labs/terraform-provider-panther

Repository files navigation

This repo is under active development and is not recommended for production use

Panther Terraform Provider

Terraform provider for Panther resources

This template repository is built on the Terraform Plugin Framework. The template repository built on the Terraform Plugin SDK can be found at terraform-provider-scaffolding. See Which SDK Should I Use? in the Terraform documentation for additional information.

Requirements

Building The Provider

  1. Clone the repository
  2. Enter the repository directory
  3. Build the provider using the Go install command:
go install

Adding Dependencies

This provider uses Go modules. Please see the Go documentation for the most up to date information about using Go modules.

To add a new dependency github.com/author/dependency to your Terraform provider:

go get github.com/author/dependency
go mod tidy

Usage

Use the examples directory as a guide for setting up the provider.

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).

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

To generate or update documentation, run go generate.

In order to run the full suite of Acceptance tests, run make testacc.

Note: Acceptance tests create real resources and may cost money to run.

PANTHER_API_URL=<Panther GraphQL URL> \
PANTHER_API_TOKEN=<Panther GraphQL API Token> \
make testacc

There are also complete examples under the examples directory. If you want to try out the provider as you are building it, you can add a .terraformrc file in your home dir which contains the following:

provider_installation {
  dev_overrides {
    "panther-labs/panther" = "{PATH}"
  }
  direct {}
}

where PATH is the path that your go binaries are. This will either be your GOBIN var if it's set, or {GOPATH}/bin.

Then you can normally run terraform commands to create the resources, like

terraform plan -var="var1=value1" -var="var2=value2" ...

or by adding variables to a temporary .tfvars file and running:

terraform plan -var-file="your-file.tfvars"

As this will create actual resources in your dev environment, make sure to run

terraform destroy ...

when you are done with testing, so no lingering resources are left.