Skip to content

ghostsecurity/terraform-provider-ghost

Repository files navigation

terraform-provider-ghost

The Ghost Security terraform provider.

Terraform Registry: ghostsecurity/ghost

Development

Refer to the Hashicorp Documentation for more details on developing custom providers.

Pre-requisites

Install Provider

To build and install the provider locally run make install.

To configure terraform to use the locally installed provider instead of the terraform registry, edit the ~/.terraformrc file as follows:

provider_installation {
  dev_overrides {
      "ghostsecurity/ghost" = "<PATH>"
  }

  direct {}
}

The value for <PATH> should be GOBIN path where Go installs binaries. This will either be the value returned from go env GOBIN or the default path of $HOME/go/bin if empty.

Use Local Provider

With the terraform provider installed locally you should be abled to use it by specifying the source in the required_providers block to match what was specified in the dev_overrides block of your ~/.terraformrc.

Example main.tf:

terraform {
  required_providers {
    ghost = {
      source = "ghostsecurity/ghost",
    }
  }
}

provider "ghost" {
}

resource "ghost_log_forwarder" "example" {
    name = "example"
}

output "subject_id" {
    value = ghost_log_forwarder.example.subject_id
}

Releasing a new version

Tag a new release version using the GitHub releases and the release workflow will run to build the new provider version for all the supported platforms. Release version tag must be a semantic version starting with v (for example v0.7.2).

Acceptance Tests

To run the acceptance tests you must first set a valid GHOST_API_KEY in the environment. Running make test-acc will run the acceptance tests to exercise the various terraform resources using the actual API which will create/destroy real resources in the platform.