How do I use Metabase with Google Cloud Run?
In this guide, we will deploy Metabase, an open-source business intelligence tool, on Google Cloud Run using Pulumi. Google Cloud Run allows you to run stateless containers that are invocable via web requests or Pub/Sub events.
We will:
- Create a new Google Cloud Run service.
- Use a Docker image of Metabase.
- Configure the service with appropriate environment variables.
Below is the Pulumi program in TypeScript that accomplishes this:
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
// Define the configuration for the Cloud Run service
const service = new gcp.cloudrun.Service("metabase-service", {
location: "us-central1",
template: {
spec: {
containers: [{
image: "metabase/metabase:latest",
envs: [
{ name: "MB_DB_TYPE", value: "postgres" },
{ name: "MB_DB_DBNAME", value: "metabase" },
{ name: "MB_DB_PORT", value: "5432" },
{ name: "MB_DB_USER", value: "metabase" },
{ name: "MB_DB_PASS", value: "yourpassword" },
{ name: "MB_DB_HOST", value: "your-db-host" },
],
}],
},
},
traffics: [{
percent: 100,
latestRevision: true,
}],
});
// Allow public (unauthenticated) access to the service
const iamMember = new gcp.cloudrun.IamMember("metabase-service-iam", {
service: service.name,
location: service.location,
role: "roles/run.invoker",
member: "allUsers",
});
// Export the URL of the deployed service
export const serviceUrl = service.statuses[0].url;
Key Points
- Google Cloud Run Service: We create a new Cloud Run service using the Metabase Docker image.
- Environment Variables: Configure environment variables required by Metabase to connect to a PostgreSQL database.
- IAM Configuration: Allow public access to the Cloud Run service by assigning the
roles/run.invoker
role toallUsers
. - Service URL: Export the URL of the deployed service for easy access.
Summary
We have successfully deployed Metabase on Google Cloud Run using Pulumi. This setup includes creating a Cloud Run service, configuring it with the necessary environment variables, and allowing public access to the service. The URL of the deployed service is exported at the end.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.