Documentation

Documentation

Manage monitors with Terraform

Configure, import, and review PageLantern HTTP and API monitors with the Terraform provider preview.

Last updated November 29, 2026

How do I configure access for Terraform?

Create a workspace API key with monitors:read and monitors:write scopes. Supply the key as PAGELANTERN_API_KEY through your shell or CI secret store. Use a separate key for each workspace or environment.

The provider defaults to https://pagelantern.com. Set PAGELANTERN_BASE_URL only when you intend to use another trusted PageLantern deployment.

How do I load the provider preview?

Install Terraform and use the Go version declared in the provider’s go.mod. If you have the provider source, run these commands from its directory. They build the provider into a temporary directory and configure Terraform to load that binary. Skip terraform init for this local development override.

Build and load a local provider
demo=$(mktemp -d)
mkdir "$demo/plugins"
go build -mod=readonly -o "$demo/plugins/terraform-provider-pagelantern" .

cat > "$demo/terraform.rc" <<EOF
provider_installation {
  dev_overrides {
    "pagelantern/pagelantern" = "$demo/plugins"
  }
}
EOF
export TF_CLI_CONFIG_FILE="$demo/terraform.rc"

How do I declare a monitor?

Save the example as main.tf in the temporary directory. Choose an endpoint you are authorized to monitor and set the check interval to one your workspace supports. Run terraform -chdir="$demo" plan to review the changes, then terraform -chdir="$demo" apply to apply them.

The resource supports HTTP and API monitors with GET or HEAD requests. Manage request headers, authentication profiles, API steps, and alert destinations in PageLantern.

main.tf
terraform {
  required_providers {
    pagelantern = {
      source = "pagelantern/pagelantern"
    }
  }
}

resource "pagelantern_monitor" "homepage" {
  name             = "Homepage availability"
  url              = "https://example.com/"
  interval_seconds = 300
  timeout_ms       = 5000
  expected_status  = 200
}

How do I import or remove an existing monitor?

Match the existing monitor’s required fields in your configuration, replace 12345 with its ID, and run the import. Review the resulting plan to check for unintended updates.

Destroying a managed resource deletes the monitor from PageLantern. To keep it while handing management back to the workspace, remove the state binding and configuration together as a reviewed change.

Import and review
terraform -chdir="$demo" import pagelantern_monitor.homepage 12345
terraform -chdir="$demo" plan