Skip to content

uptimerobot/terraform-provider-uptimerobot

Repository files navigation

Terraform Provider for UptimeRobot

This Terraform provider allows you to manage your UptimeRobot resources programmatically.

Maintainer Notice

This is the official UptimeRobot Terraform provider.

Requirements

  • Terraform >= 1.5 or OpenTofu >= 1.7
  • An UptimeRobot account.
  • An UptimeRobot API Key. You can generate your Main API Key from your UptimeRobot dashboard under "My Settings" -> "API Settings" -> "Main API Key".

Installation

To use this provider, add the following to your Terraform configuration, then run terraform init.

terraform {
  required_providers {
    uptimerobot = {
      source  = "uptimerobot/uptimerobot"
      version = "~> 1.3.0"
    }
  }
}

provider "uptimerobot" {
  # Configuration options
}

Provider Configuration

The provider requires an API key to interact with the UptimeRobot API.

provider "uptimerobot" {
  api_key = "YOUR_UPTIMEROBOT_API_KEY"
  # api_url = "https://api.uptimerobot.com/v3" # Optional: Default is UptimeRobot API v3 URL
}

Argument Reference

  • api_key (String, Required): Your UptimeRobot Main API Key.
  • api_url (String, Optional): The base URL for the UptimeRobot API. Defaults to https://api.uptimerobot.com/v3. Useful if UptimeRobot offers different API endpoints or for testing purposes.

Usage Examples

Here's an example of how to create an UptimeRobot monitor, a maintenance window, an integration, and a public status page:

terraform {
  required_providers {
    uptimerobot = {
      source  = "uptimerobot/uptimerobot"
      version = "~> 1.3.0"
    }
  }
}

provider "uptimerobot" {
  api_key = "YOUR_UPTIMEROBOT_API_KEY"
}

resource "uptimerobot_monitor" "website" {
  name     = "My Website"
  type     = "HTTP"
  url      = "https://example.com"
  interval = 300
}

resource "uptimerobot_maintenance_window" "weekly" {
  name     = "Weekly Maintenance"
  type     = "weekly"
  duration = 60
  interval = "weekly"
  time     = "23:00"
}

resource "uptimerobot_integration" "slack" {
  name  = "Team Slack"
  type  = "slack"
  value = "https://hooks.slack.com/services/XXXXX/YYYYY/ZZZZZ"
}

resource "uptimerobot_psp" "main_status" {
  name        = "Example.com Status"
  monitor_ids = [uptimerobot_monitor.website.id]
}

Resource Reference

Detailed documentation for the resources supported by this provider can be found in the docs/resources/ directory or by clicking the links below:

Data Source Reference

This provider does not currently expose data sources. When data sources are added, their documentation will live under docs/data-sources/.

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine (version 1.24 or higher is recommended).

Building The Provider

  1. Clone the repository.

  2. Enter the repository directory.

  3. Build the provider using the Go install command:

    go install

    This will build the provider and put the provider binary in the $GOPATH/bin directory (or $GOBIN if set).

Local Development and Testing

To use your locally built provider for testing with a Terraform configuration, you can specify the development override in your Terraform CLI configuration file. See Provider Development Overrides.

Example ~/.terraformrc or terraform.rc:

provider_installation {
  dev_overrides {
    "uptimerobot/uptimerobot" = "/path/to/your/gopath/bin" # or wherever 'go install' places the binary
    # For example: "uptimerobot/uptimerobot" = "$HOME/go/bin"
  }
  # For TF 0.13+ installations, you can also use a direct path to the binary
  # fs_mirror {
  #   "https://registry.terraform.io/providers/uptimerobot/uptimerobot" = "/path/to/your/project/terraform-provider-uptimerobot"
  # }
}

Generating Documentation

If you have tfplugindocs installed, you can generate or update documentation by running:

go generate

Running Acceptance Tests

Acceptance tests create real resources against the UptimeRobot API and may incur costs or affect your UptimeRobot account. Ensure you have the UPTIMEROBOT_API_KEY environment variable set before running tests.

To run the full suite of Acceptance tests:

make testacc

Note: Acceptance tests create real resources

Adding Dependencies

This provider uses Go modules. To add a new dependency github.com/author/dependency:

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

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

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines on proposing changes, running tests, and opening pull requests.

License

This provider is distributed under the Mozilla Public License Version 2.0. See the LICENSE file for more information.

About

Terraform Provider for UptimeRobot

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors

Languages