-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔨(project) provision metabase instance using terraform
Using `make bootstrap` now automates Metabase instance provisioning: - metabase admin user is created - QualiCharge API database is set as a datasource
- Loading branch information
Showing
9 changed files
with
134 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,7 @@ venv.bak/ | |
|
||
# -- Tools | ||
.coverage | ||
|
||
# -- Provisioning | ||
provisioning/.terraform* | ||
provisioning/terraform.tfstate* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,11 +31,11 @@ make bootstrap | |
> 👉 Cette commande doit préparer votre environnement et builder les images | ||
> Docker nécessaires au démarrage de votre environnement. | ||
Une fois votre environnement de travail initialisé, vous pouvez lancer le projet en | ||
utilisant : | ||
Une fois votre environnement de travail initialisé, vous pouvez lancer le projet | ||
en utilisant : | ||
|
||
``` | ||
make run | ||
make run-all | ||
``` | ||
|
||
Les services QualiCharge doivent maintenant tourner sur votre poste : | ||
|
@@ -55,6 +55,16 @@ Et enfin, pour lancer les tests du projet : | |
make test | ||
``` | ||
|
||
## Explorer les données collectées avec Metabase | ||
|
||
Si vous avez utilisé la commande `make bootstrap` pour initialiser le projet, | ||
vous devez avoir provisionné une instance de Metabase qui est accessible depuis | ||
un navigateur sur l'URL suivante : | ||
[http://localhost:3000](http://localhost:3000). | ||
|
||
> :bulb: Vous pouvez vous connecter en utilisant le login `[email protected]` et | ||
> le mot de passe `supersecret`. | ||
## Utilisation du client d'API et du CLI `qcc` | ||
|
||
Voir la documentation du projet : [./src/client/](./src/client/) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script will run at project bootstrap to initialize a metabase instance | ||
# | ||
# It is inspired from the metabase setup script of the metabase terraform provider: | ||
# github.com/bnjns/terraform-provider-metabase | ||
|
||
set -eo pipefail | ||
|
||
# Utilities | ||
declare COMPOSE_RUN="docker compose run --rm -T" | ||
declare CURL="${COMPOSE_RUN} curl" | ||
declare JQ="${COMPOSE_RUN} jq" | ||
|
||
# Vars | ||
declare METABASE_HOST="http://metabase:3000" | ||
declare METABASE_EMAIL="[email protected]" | ||
declare METABASE_PASSWORD="supersecret" | ||
|
||
# Get the setup token | ||
echo "⚙️ Getting setup token…" | ||
if ! setupToken=$(${CURL} -s --fail "${METABASE_HOST}/api/session/properties" | ${JQ} -er '."setup-token"'); then | ||
echo "Failed to extract setup token" | ||
exit 2 | ||
fi | ||
|
||
echo "⚙️ Configuring metabase…" | ||
${JQ} -n "{ \ | ||
database: null, \ | ||
invite: null, \ | ||
prefs: { \ | ||
allow_tracking: false, \ | ||
site_locale: \"en\", \ | ||
site_name: \"QualiCharge\" \ | ||
}, \ | ||
user: { \ | ||
email: \"${METABASE_EMAIL}\", \ | ||
first_name: \"Admin\", \ | ||
last_name: \"User\", \ | ||
password: \"${METABASE_PASSWORD}\", \ | ||
password_confirm: \"${METABASE_PASSWORD}\", \ | ||
site_name: \"QualiCharge\" \ | ||
}, \ | ||
token: \"${setupToken}\" \ | ||
}" | ${CURL} -s --fail \ | ||
-X POST \ | ||
-H "Content-Type: application/json" \ | ||
-d @- \ | ||
"${METABASE_HOST}/api/setup" | ||
|
||
echo "✅ all done." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
METABASE_HOST=http://metabase:3000 | ||
[email protected] | ||
METABASE_PASSWORD=supersecret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Database | ||
resource "metabase_database" "qualicharge" { | ||
engine = "postgres" | ||
name = "QualiCharge API" | ||
|
||
details = jsonencode({ | ||
host = "postgresql" | ||
port = 5432 | ||
dbname = "qualicharge-api" | ||
user = "qualicharge" | ||
}) | ||
details_secure = jsonencode({ | ||
password = "pass" | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
terraform { | ||
required_providers { | ||
metabase = { | ||
source = "bnjns/metabase" | ||
version = "0.9.0" | ||
} | ||
} | ||
} | ||
|
||
provider "metabase" { | ||
# Configured using environment variables | ||
# See env.d/terraform | ||
} |