This project runs acceptance tests against a separate incident-io-terraform account, with its own isolated Slack workspace.
The account is empty and marked as a demo to enable all feature gates.
If you work at incident.io as an engineer, you may wish to develop this provider against your own local instance of the product, such as when building Terraform resources for as-yet released features.
You can do this by:
- Getting an API key with the relevant scopes from your local instance
- Running tests with the following environment set:
export INCIDENT_ENDPOINT="https://incident-io-name.eu.ngrok.io/api/public"
export INCIDENT_API_KEY="inc_development_<token>"
This points the provider at your local instance via ngrok.
If you need to regenerate the client, you first need to copy the following files over from core/server/api/public/gen/http/
:
openapi.json
openapi.yaml
openapi3-secret.json
openapi3.json
openapi3.yaml
# If your core repository is one level up, this would be:
cp ../core/server/api/public/gen/http/openapi.json internal/apischema
cp ../core/server/api/public/gen/http/openapi.yaml internal/apischema
cp ../core/server/api/public/gen/http/openapi3-secret.json internal/apischema
cp ../core/server/api/public/gen/http/openapi3.json internal/apischema
cp ../core/server/api/public/gen/http/openapi3.yaml internal/apischema
And then run make internal/client/client.gen.go
The best way to develop against this provider is to write tests. You can run
tests either with make testacc
or targeting tests like so:
TF_ACC=1 dlv test ./internal/provider -- -test.run=TestAccIncidentCatalogEntriesResource
Tests run against a real API, either the production/staging incident.io API or whatever you may be running locally (for incident.io staff). If you're staff, it's best to use a localhost endpoint for lower latency if possible.
See the above for setting environment variables, otherwise configure your tests just as you would for a normal environment.
There may be changes where you want to be running the provider itself, rather than just running tests. To do that you need to:
- Install Terraform:
brew install hashicorp/tap/terraform
- Create yourself a project
mkdir tmp/project
- Create a
dev.tfrc
file, insidetmp/project
so thatterraform
uses your local version of the provider:
provider_installation {
dev_overrides {
"incident-io/incident" = "/<PATH-TO-REPO>/terraform-provider-incident/bin"
}
direct {}
}
- Create a
main.tf
file including any resources that you want to create (look inexamples/resources
for some nice examples)
terraform {
required_providers {
incident = {
source = "incident-io/incident"
version = "3.0.0"
}
}
}
provider "incident" {}
resource "incident_catalog_type" "service_tier" {
name = "Service Tier"
description = "Level of importance for each service"
}
- Build the provider binary
make build
- Start your
terraform
server:
TF_CLI_CONFIG_FILE=./dev.tfrc terraform init
- You can now plan and apply your Terraform configuration:
TF_CLI_CONFIG_FILE=./dev.tfrc terraform plan
TF_CLI_CONFIG_FILE=./dev.tfrc terraform apply