Skip to content

cortexapps/terraform-provider-cortex

Repository files navigation

Cortex Terraform Provider

Requirements

Building The Provider

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

Using the provider

Add the following block into your Terraform files (note that this provider requires Terraform 1.5 or greater):

terraform {
  required_providers {
    cortex = {
      source  = "cortex/cortex"
      version = ">= 0.1"
    }
  }
  required_version = ">= 1.5.0"
}

You'll need to set the environment variable CORTEX_API_TOKEN with your Cortex API token.

You can optionally further configure the provider either inline in terraform:

provider "cortex" {
  token        = "my-api-token"
  base_api_url = "https://api.getcortexapp.com" // default value, only set if changing
}

...or via ENV:

Key Description Default Value
CORTEX_API_TOKEN Your Cortex.io API token ""
CORTEX_API_URL The base API URL for Cortex's API. "https://api.getcortexapp.com"

Resource Types

This provider comes with the following resource types:

And the following data sources:

Examples on each of these can be found in the examples/ folder.

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 often cost money to run.

make testacc

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

Then commit the changes to go.mod and go.sum.