Metabase

Pulumi Official
Package maintained by Pulumi
v0.0.2 published on Thursday, Jul 21, 2022 by Pulumi

You can use the Pulumi Metabase Component to help you get started quickly running Metabase in the cloud. Currently this Component only supports AWS. The code below will show you examples of each resources supported in this Component, but please refer to the API Docs for more detailed descriptions and information about each resource.

Quick Start

The following steps will get you up and running with Metabase on AWS with very little effort. Once you have completed the steps you will have an RDS Database, Metabase running in a Fargate Task, and a Load Balancer.

Configure Environment

Before you get started using Pulumi, let’s run through a few quick steps to ensure your environment is set up correctly.

Install Pulumi

Install Pulumi on macOS through Homebrew:

$ brew install pulumi/tap/pulumi

Install Pulumi on Linux by running the installation script:

$ curl -fsSL https://get.pulumi.com | sh

Install Pulumi on Windows using elevated permissions through the Chocolatey package manager:

> choco install pulumi

For alternative installation instructions (e.g. script-based installation, binaries, etc.) or troubleshooting, see Download and Install.

Next, install the required language runtime, if you have not already.

Install Language Runtime

Choose Your Language

Install Node.js.

Install Python version 3.6 or later. To reduce potential issues with setting up your Python environment on Windows or macOS, you should install Python through the official Python installer.

Install Go.

Install .NET SDK.

Good news! You don't have to install anything else to write Pulumi programs in YAML.

Configure Pulumi to access your AWS account

Pulumi requires cloud credentials to manage and provision resources. You must use an IAM user account that has Programmatic access with rights to deploy and manage resources handled through Pulumi.

If you have previously installed and configured the AWS CLI, Pulumi will respect and use your configuration settings.

If you do not have the AWS CLI installed or plan on using Pulumi from within a CI/CD pipeline, retrieve your access key ID and secret access key and then set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables on your workstation.

$ export AWS_ACCESS_KEY_ID=<YOUR_ACCESS_KEY_ID>
$ export AWS_SECRET_ACCESS_KEY=<YOUR_SECRET_ACCESS_KEY>
$ export AWS_ACCESS_KEY_ID=<YOUR_ACCESS_KEY_ID>
$ export AWS_SECRET_ACCESS_KEY=<YOUR_SECRET_ACCESS_KEY>
> $env:AWS_ACCESS_KEY_ID = "<YOUR_ACCESS_KEY_ID>"
> $env:AWS_SECRET_ACCESS_KEY = "<YOUR_SECRET_ACCESS_KEY>"

For additional information on setting and using AWS credentials, see AWS Setup.

Next, you’ll create a new Pulumi project.

Create New Project

Now that you have set up your environment by installing Pulumi, installing your preferred language runtime, and configuring your AWS credentials, let’s create your first Pulumi program.

$ mkdir metabase-quickstart && cd metabase-quickstart
$ pulumi new aws-typescript
$ mkdir metabase-quickstart && cd metabase-quickstart
$ pulumi new aws-python
# from within your $GOPATH
$ mkdir metabase-quickstart && cd metabase-quickstart
$ pulumi new aws-go
$ mkdir metabase-quickstart && cd metabase-quickstart
$ pulumi new aws-csharp
$ mkdir metabase-quickstart && cd metabase-quickstart
$ pulumi new aws-yaml

The pulumi new command creates a new Pulumi project with some basic scaffolding based on the cloud and language specified.

Note

If this is your first time running pulumi new or other pulumi commands, you may be prompted to log in to the Pulumi Service. The Pulumi CLI and Pulumi Service work in tandem to deliver a reliable experience. It's free for individual use, with features available for teams, and self-managed options are also available. Hitting Enter at the prompt opens a browser for you to sign in or sign up.

After logging in, the CLI will proceed with walking you through creating a new project.

First, you will be asked for a project name and description. Hit ENTER to accept the default values or specify new values.

Next, you will be asked for the name of a stack. Hit ENTER to accept the default value of dev.

Finally, you will be prompted for some configuration values for the stack. For AWS projects, you will be prompted for the AWS region. You can accept the default value or choose another value like us-west-2.

What are projects and stacks? Pulumi projects and stacks let you organize Pulumi code. Consider a Pulumi project to be analogous to a GitHub repo—a single place for code—and a stack to be an instance of that code with a separate configuration. For instance, Project Foo may have multiple stacks for different development environments (Dev, Test, or Prod), or perhaps for different cloud configurations (geographic region for example). See Organizing Projects and Stacks for some best practices on organizing your Pulumi projects and stacks.

After some dependency installations from npm, your project and stack will be ready.

Install Metabase Component

Next you will need to install the Metabase Component so you can use it in your program.

Yarn
$ yarn add @pulumi/metabase
NPM
$ npm install @pulumi/metabase

After the command completes, the project and stack will be ready.

Install Metabase Component

Next you will need to install the Metabase Component so you can use it in your program.

$ pip3 install pulumi_metabase

After the command completes, the project and stack will be ready.

Install Metabase Component

Next you will need to install the Metabase Component so you can use it in your program.

$ go get -u github.com/pulumi/pulumi-metabase/sdk

After the command completes, the project and stack will be ready.

Install Metabase Component

Next you will need to install the Metabase Component so you can use it in your program.

$ dotnet add package Pulumi.Metabase

Update Code

Now that you have all your dependencies installed and your project configured, you can now add the code that will provision your Metabase Service.

Replace your index.ts with the following:

import * as pulumi from "@pulumi/pulumi";
import * as metabase from "@pulumi/metabase";

const metabaseService = new metabase.Metabase("metabaseService", {});
export const url = metabaseService.dnsName;

Replace your __main__.py with the following:

import pulumi
import pulumi_metabase as metabase

metabase_service = metabase.Metabase("metabaseService")
pulumi.export("url", metabase_service.dns_name)

Replace your main.go with the following:

package main

import (
	"github.com/pulumi/pulumi-metabase/sdk/go/metabase"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		metabaseService, err := metabase.NewMetabase(ctx, "metabaseService", nil)
		if err != nil {
			return err
		}
		ctx.Export("url", metabaseService.DnsName)
		return nil
	})
}

Replace your Program.cs with the following:

using Pulumi;
using Metabase = Pulumi.Metabase;

await Deployment.RunAsync(() =>
{
   var metabaseService = new Metabase.Metabase("metabaseService");

   return new Dictionary<string, object?>
   {
      ["url"] = metabaseService.DnsName
   };
});

Replace your Pulumi.yaml with the following:

name: metabase-yaml
runtime: yaml
resources:
    metabaseService:
        type: "metabase:index:Metabase"
outputs:
    url: ${metabaseService.dnsName}

Deploy

Once you have updated your code you are ready to deploy your Metabase Component. To do so, just run the the following command:

$ pulumi up

First Pulumi will perform a preview showing you exactly what will be created. Once the preview is complete Pulumi will ask you if you want to continue. Select yes to proceed to actually provisioning the service.

All the resources will take a few minutes to fully provision. Once the update has completed it is likely it will take a few more minutes for the Metabase task to finishing provisioning and start accepting traffic.

(Optional) Destroy

You can destroy all the resources by running pulumi destroy. This will ultimately delete your Metabase Service’s database so you will lose all stored data and have to start from scratch if you provision a new Metabase service.

Full Examples

Below you will find complete examples (all arguments supplied) for the Metabase Components.

import * as pulumi from "@pulumi/pulumi";
import * as metabase from "@pulumi/metabase";

const metabaseService = new metabase.Metabase("metabaseService", {
    vpcId: "vpc-123",
    networking: {
        ecsSubnetIds: [
            "subnet-123",
            "subnet-456",
        ],
        dbSubnetIds: [
            "subnet-789",
            "subnet-abc",
        ],
        lbSubnetIds: [
            "subnet-def",
            "subnet-ghi",
        ],
    },
    domain: {
        hostedZoneName: "example.com",
        domainName: "metabase.example.com",
    },
});
export const url = metabaseService.dnsName;
import pulumi
import pulumi_metabase as metabase

metabase_service = metabase.Metabase("metabaseService",
    vpc_id="vpc-123",
    networking=metabase.NetworkingArgs(
        ecs_subnet_ids=[
            "subnet-123",
            "subnet-456",
        ],
        db_subnet_ids=[
            "subnet-789",
            "subnet-abc",
        ],
        lb_subnet_ids=[
            "subnet-def",
            "subnet-ghi",
        ],
    ),
    domain=metabase.CustomDomainArgs(
        hosted_zone_name="example.com",
        domain_name="metabase.example.com",
    ))
pulumi.export("url", metabase_service.dns_name)
package main

import (
	"github.com/pulumi/pulumi-metabase/sdk/go/metabase"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		metabaseService, err := metabase.NewMetabase(ctx, "metabaseService", &metabase.MetabaseArgs{
			VpcId: pulumi.String("vpc-123"),
			Networking: &metabase.NetworkingArgs{
				EcsSubnetIds: pulumi.StringArray{
					pulumi.String("subnet-123"),
					pulumi.String("subnet-456"),
				},
				DbSubnetIds: pulumi.StringArray{
					pulumi.String("subnet-789"),
					pulumi.String("subnet-abc"),
				},
				LbSubnetIds: pulumi.StringArray{
					pulumi.String("subnet-def"),
					pulumi.String("subnet-ghi"),
				},
			},
			Domain: &metabase.CustomDomainArgs{
				HostedZoneName: pulumi.String("example.com"),
				DomainName:     pulumi.String("metabase.example.com"),
			},
		})
		if err != nil {
			return err
		}
		ctx.Export("url", metabaseService.DnsName)
		return nil
	})
}
using Pulumi;
using Metabase = Pulumi.Metabase;

await Deployment.RunAsync(() =>
{
   var metabaseService = new Metabase.Metabase("metabaseService", new Metabase.MetabaseArgs
    {
        VpcId = "vpc-123",
        Networking = new Metabase.Inputs.NetworkingArgs
        {
            EcsSubnetIds =
            {
                "subnet-123",
                "subnet-456",
            },
            DbSubnetIds =
            {
                "subnet-789",
                "subnet-abc",
            },
            LbSubnetIds =
            {
                "subnet-def",
                "subnet-ghi",
            },
        },
        Domain = new Metabase.Inputs.CustomDomainArgs
        {
            HostedZoneName = "example.com",
            DomainName = "metabase.example.com",
        },
    });

   return new Dictionary<string, object?>
   {
      ["url"] = metabaseService.DnsName
   };
});
name: metabase-yaml
runtime: yaml
resources:
    metabaseService:
        type: "metabase:index:Metabase"
        properties:
            vpcId: "vpc-123"
            networking:
                ecsSubnetIds: [ "subnet-123", "subnet-456" ]
                dbSubnetIds: [ "subnet-789", "subnet-abc" ]
                lbSubnetIds: [ "subnet-def", "subnet-ghi" ]
            domain:
                hostedZoneName: "example.com"
                domainName: "metabase.example.com"
outputs:
    url: ${metabaseService.dnsName}