A Terraform provider that lets you manage your Metabase instance, because why not Terraform the world?
⚠️ This provider is not abandoned, but I changed job and no longer use this provider on a day-to-day basis so feature development will be slow. If you have a feature request please do raise an issue and I will be more than happy to take a look at it!
Metabase is a simple analytics tool which allows anyone to easily learn and make decisions from their company's data. It allows you to query data directly from your databases (called "questions"), which you can store and share with others, as well as generate reports.
As with everything, software engineers are incredibly lazy and like to avoid configuring things manually so this provider lets you manage your Metabase instance using Terraform and any standard infrastructure-as-code tooling and processes you may already have.
This provider is published to the public Terraform
Registry: https://registry.terraform.io/providers/bnjns/metabase/latest. To use the provider, simply add it to your
Terraform required_providers
block and configure the provider:
terraform {
required_providers {
metabase = {
source = "bnjns/metabase"
version = "~> 0.0"
}
}
}
provider "metabase" {
host = "<your metabase host/ip>"
}
See the documentation on the Terraform registry for more details.
For local development, you may also want one of:
- Docker and Docker Compose
- Java Runtime Environment >= 1.8
Simply clone this repo to your desired location:
$ git clone git@github.com:bnjns/terraform-provider-metabase.git
Install the Go dependencies:
$ go mod download
To build the provider and install into your GOPATH
:
$ go install
You can configure Terraform to use a local build by adding the following to you ~/.terraformrc
file:
provider_installation {
dev_overrides {
"bnjns/metabase" = "</path/to/GOPATH>/bin"
}
direct {}
}
Note: You must include
direct {}
otherwise all other providers will fail to install.
It is recommended that you run a local copy of Metabase to test against when developing, and inspect the API. You can either use Docker to run Metabase or run it manually.
Once Metabase is started, you'll need to navigate to http://localhost:3000
and configure Super User. Make sure you
remember the username (email) and password so that you can configure the provider when testing.
Simply use the included docker
set-up to run Metabase:
$ docker-compose up metabase
This will start Metabase on port 3000.
This also includes a selection of other databases, which you can use to experiment with. To start the entire network:
$ docker-compose up
Download the JAR to a sensible location and run:
$ java \
-DMB_PASSWORD_COMPLEXITY=weak \
-DMB_SEND_EMAIL_ON_FIRST_LOGIN_FROM_NEW_DEVICE='false' \
-jar metabase.jar
This will start Metabase on port 3000.
When Metabase first starts, it will require some basic initial set up before it can be used. You can set it up manually by visiting https://localhost:3000 and following the steps, or by running the included script:
$ scripts/setup_metabase.sh
This will create a user with email example@example.com
and password password
.
The documentation can be auto-generated using tfplugindocs
:
go generate
Make sure you have Metabase running and configured using the included script, as both the client and provider tests require an actual instance of Metabase to interact with.
To run the unit tests:
$ go test -v ./...
To run the provider acceptance tests:
$ TF_ACC=1 go test -v ./... -run "^TestAcc"
Note: While tests should randomly generate unique names in order to prevent conflicts, you may need to stop and restart Metabase between test runs (ensure you use
--force-recreate
if using Docker).
Releasing is handled automatically by GitHub Actions and
Hashicorp's terraform-provider-release
action. An admin will simply tag the latest release to trigger the pipeline.