Code Monkey home page Code Monkey logo

terraform-provider-metabase's People

Contributors

ellingtonjp avatar flovouin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

terraform-provider-metabase's Issues

Impossible to setup linked filters in dashboards

Metabase has a very useful feature called linked filters, but it seems impossible to use it with this provider. I describe my attempts below:

Let's take a simplest possible dashboard resource with two parameters:

resource "metabase_dashboard" "dashboard" {
  name        = "๐Ÿ“ˆ Some great dashboard"
  description = "๐Ÿ’ก With plenty of actionable stuff."

  parameters_json = jsonencode([
    {
      id                  = "12345678"
      name                = "foo"
      slug                = "foo"
      type                = "string/="
      sectionId           = "string"
    },
    {
      id                  = "23456789"
      name                = "bar"
      slug                = "bar"
      type                = "string/="
      sectionId           = "string"
    },
  ])

  cards_json = jsonencode([])
}

Usually when I want to use some new feature with this provider, I make changes in UI and run terraform plan to see what's missing in my code.
image

I run terraform plan and get:
image

Strange, let's take a look at network traffic:
image
The response for GET /api/dashboard/:id has included an appropriate field: filteringParameters but terraform provider doesn't pick it up.

Let's try to add it to the config:

resource "metabase_dashboard" "dashboard" {
  name        = "๐Ÿ“ˆ Some great dashboard"
  description = "๐Ÿ’ก With plenty of actionable stuff."

  parameters_json = jsonencode([
    {
      id                  = "12345678"
      name                = "foo"
      slug                = "foo"
      type                = "string/="
      sectionId           = "string"
      filteringParameters = ["23456789"]
    },
    {
      id                  = "23456789"
      name                = "bar"
      slug                = "bar"
      type                = "string/="
      sectionId           = "string"
      filteringParameters = ["12345678"]
    },
  ])

  cards_json = jsonencode([])
}

and run terraform apply...
image
Now it shows as a change (it shouldn't because this is already the state of the server).
After confirmation I get an error:
image
Also network traffic inspections shows that the PUT request did not include the filteringParameters at all:
image
which results in my changes made in UI being rolled back:
image

Seems to me that maybe there is some json processing in the provider both in parsing GET responses and in creating PUT requests which keeps only the known fields, filteringParameters not being among them. Please let me know if I'm missing something obvious here or just doing it wrong. Cheers!

Support API Keys

Metabase added support for API Keys in v0.49. It would be wonderful if we could supply an api key instead of username+password in the provider setup.

Error when creating a collection on color attribute

Hi,
With

  • metabase v0.48.3
  • provider version 0.3.0

I have an error when I create a new collection, the collection is well created but I have the following on console when doing the terraform apply

โ”‚ Error: Provider produced inconsistent result after apply
โ”‚ 
โ”‚ When applying changes to metabase_collection.my_business_reports, provider
โ”‚ "provider[\"registry.terraform.io/flovouin/metabase\"]" produced an unexpected new value: .color: was
โ”‚ cty.StringVal("#cdeabc"), but now null.
โ”‚ 
โ”‚ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Thank you for your work ๐Ÿ‘

Fix bug caused by changing Metabase Analytics permissions

Problem

The metabase_permissions_graph resource will error if the Metabase Analytics (pro feature) permissions are changed. Example:

โ•ท
โ”‚ Error: Unexpected error while calling the Metabase API for operation 'get permissions graph'.
โ”‚ 
โ”‚ json: cannot unmarshal object into Go struct field PermissionsGraphDatabaseAccess.groups.data.schemas of type metabase.PermissionsGraphDatabaseAccessSchemas
โ•ต

This is caused by Metabase changing the response to /api/permissions/graph to a schema different than what's in metabase-api.yml. Thus the client is erroring out.

Reproducing

  • Start a fresh instance of Metabase Pro using Postgres
    • The use of Postgres is important, for some reason I couldn't reproduce this with H2. Haven't tested any others.
  • Go to Admin->Permissions->Collections->Metabase analytics
  • Give "All Users" view permission

Apply the following terraform:

terraform {
  required_version = ">= 1.0"
  required_providers {
    metabase = {
      source  = "local/providers/metabase"
      version = "1.0.0"
    }
  }
}

provider "metabase" {
  endpoint = "http://localhost:3000/api"
  username = < user you created >
  password = < password you created >
}

import {
  to = metabase_permissions_graph.read
  id = 1
}

resource "metabase_permissions_graph" "read" {
  advanced_permissions = false
  permissions          = []
  provider = metabase
}

Cause

After changing the metabase analytics permissions, response schema from /api/permissions/graph will differ from what's defined in metabase-api.yml, leading to errors in the generated client.

Here is a successful response. This was taken from a fresh instance of Metabase Pro with nothing but the sample database. Note the database 13371337 -- this is the metabase analytics database.

{
    "revision": 17,
    "groups": {
        "1": {
            "1": {
                "download": {
                    "native": "full",
                    "schemas": "full"
                }
            }
        },
        "2": {
            "1": {
                "data": {
                    "native": "write",
                    "schemas": "all"
                },
                "download": {
                    "native": "full",
                    "schemas": "full"
                },
                "data-model": {
                    "schemas": "all"
                },
                "details": "yes"
            },
            "13371337": {
                "data": {
                    "native": "write",
                    "schemas": "all"
                },
                "download": {
                    "native": "full",
                    "schemas": "full"
                },
                "data-model": {
                    "schemas": "all"
                },
                "details": "yes"
            }
        }
    },
    "sandboxes": [],
    "impersonations": []
}

Response after modifying permissions. Note how schemas has changed from a string to an object. The OpenAPI spec only allows strings:

{
    "revision": 17,
    "groups": {
        "1": {
            "1": {
                "download": {
                    "native": "full",
                    "schemas": "full"
                }
            },
            "13371337": {
                "data": {

//  PROBLEM: `schemas` is not a string:

                    "schemas": {
                        "public": {
                            "9": {
                                "query": "all"
                            },
                            "10": {
                                "query": "all"
                            },
                            "11": {
                                "query": "all"
                            },
                            "12": {
                                "query": "all"
                            },
                            "13": {
                                "query": "all"
                            },
                            "14": {
                                "query": "all"
                            },
                            "15": {
                                "query": "all"
                            },
                            "16": {
                                "query": "all"
                            },
                            "17": {
                                "query": "all"
                            },
                            "18": {
                                "query": "all"
                            },
                            "19": {
                                "query": "all"
                            },
                            "20": {
                                "query": "all"
                            },
                            "21": {
                                "query": "all"
                            }
                        }
                    }
                }
            }
        },
        "2": {
            "1": {
                "data": {
                    "native": "write",
                    "schemas": "all"
                },
                "download": {
                    "native": "full",
                    "schemas": "full"
                },
                "data-model": {
                    "schemas": "all"
                },
                "details": "yes"
            },
            "13371337": {
                "data": {
                    "native": "write",
                    "schemas": "all"
                },
                "download": {
                    "native": "full",
                    "schemas": "full"
                },
                "data-model": {
                    "schemas": "all"
                },
                "details": "yes"
            }
        }
    }
}

Error Creating Dashboard's Cards: API Endpoint Does Not Exist

When I try to create a metabase_dashboard resource using version 0.3.0 of this provider, I receive this error:

 Error: Unexpected response while calling the Metabase API for operation 'create dashcard'.
 ...
 Status code: 404, body: "API endpoint does not exist."

In the metabase logs I see that the failing endpoint is POST /api/dashboard/5/cards.

However when I use the Metabase UI to add cards, I notice that same endpoint but with a PUT, not a POST.

Screenshot 2023-12-01 at 12 07 24 PM

I think the easy solution might be to switch the POST to a PUT when handling the metabase_dashboard resource's cards_json attribute.

Add support for Dashboard Tabs

I would like to be able to export dashboards with tabs using mbtf and be able to execute the generated HCL to build the dashboard accordingly.

Allow importing terraform permissions with granular permissions

Description

Hi @flovouin, amazing job on the provider.

I have been trying to use it manage my permissions but seems like thats not possible if granular permissions are used in metabase.

Attaching the screenshot of what I am facing when importing the metabase_permissions_graph resource :
Screenshot 2024-05-02 at 14 26 14

Is there a workaround for this? If I can still manage the rest without granular permissions.

produced an unexpected new value: .custom_details: inconsistent values for sensitive attribute

Hey there,
thank you for developing this provider. Id like to report a bug:

When applying changes to metabase_database.custom, provider "provider[\"registry.terraform.io/flovouin/metabase\"]" produced an unexpected new value: .custom_details: inconsistent values for sensitive attribute.

This is a bug in the provider, which should be reported in the provider's own issue tracker.

Terraform Code:

metabase = {
      source  = "flovouin/metabase"
      version = "0.4.0"
    }

provider "metabase" {
  endpoint = "https://${local.metabase_domain}/api"
  username = terraform_data.wait_for_metabase.input
  password = var.metabase_admin_pw
}


resource "metabase_database" "custom" {
  name       = "Warehouse"
  depends_on = [kubectl_manifest.letsencrypt_issuer_production]
  custom_details = {
    engine = "postgres"

    details_json = jsonencode({
      host             = "cluster-rw.${kubernetes_namespace.warehouse.metadata[0].name}"
      port             = data.kubernetes_secret.warehouse.data["port"]
      dbname           = data.kubernetes_secret.warehouse.data["dbname"]
      user             = data.kubernetes_secret.warehouse.data["username"]
      password         = data.kubernetes_secret.warehouse.data["password"]
      ssl              = false
      tunnel-enabled   = false
      advanced-options = false
    })

    redacted_attributes = [
      "password", 
    ]
  }


}

I have tried with both metabase 0.48 and 0.49

Request support for additional database engines

Hi @flovouin!

Your provider popped up just in time for me and my team ๐Ÿ‘ thank you very much for that!

In the docs of metabase_database resource you mentioned to create an issue for the support of additional databases. That's what this issue is all about.

It would be great for us to manage the following databases by your provider:

  • Amazon Athena
  • Amazon Redshift
  • MySQL
  • PostgreSQL

Best,
Pierre

Build `mbtf` as a release artefact

mbtf can currently be installed manually by checking out the repository and running go install. It would be nice to distribute it as a release artefact, such that it can be downloaded from GitHub directly.

Add support for all table metadata values

I would like to be able to export through mbtf all table metadata values.
Description
Visibility
Cast to a specific data type
Filtering on this field
Display values
Formatting -> Display as, Date style, abbreviate days and months, show the time, time style

Write acceptance tests

  • Card
  • Collection graph
  • Collection
  • Dashboard
  • Database
  • Permissions graph
  • Permissions group
  • Table (data source)
  • Table (resource)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.