Aller au contenu principal

Terraform provider

Provider Terraform pour gerer les projets, connexions, webhooks et approval policies Auralith en infra as code. Permet aux Platform Engineers de versionner la configuration aux cotes du reste de la stack.

Quand l'utiliser

  • Provisionner Auralith comme partie d'un environnement reproductible (staging, prod, demo).
  • Versionner les approval policies aux cotes du code applicatif.
  • Faire respecter "no manual changes" via drift detection Terraform.

Resources disponibles

ResourceDescription
auralith_projectProjet (name, slug, team)
auralith_connectionConnexion DB (host, port, db_type, secret_path)
auralith_webhookWebhook outbound (URL, events, secret)
auralith_approval_policyPolicy par action × environment_tag
auralith_api_keyAPI key scopee

Snippet HCL minimal

terraform {
required_providers {
auralith = {
source = "auralith/auralith"
version = "~> 0.1"
}
}
}

provider "auralith" {
endpoint = "https://app.auralith.io"
api_key = var.auralith_api_key
}

resource "auralith_project" "billing" {
name = "Billing service"
slug = "billing"
}

resource "auralith_connection" "billing_prod" {
project_id = auralith_project.billing.id
name = "billing-prod"
db_type = "postgres"
host = "billing-prod.cluster-xyz.eu-west-3.rds.amazonaws.com"
port = 5432
database = "billing"
user = "auralith_ro"
secret_provider = "aws_secrets"
secret_path = "arn:aws:secretsmanager:eu-west-3:..."
environment_tag = "prod"
}

resource "auralith_approval_policy" "billing_prod_patch" {
project_id = auralith_project.billing.id
action_type = "mass_patch"
environment_tag = "prod"
required = true
min_approvers = 2
}

resource "auralith_webhook" "slack_ops" {
project_id = auralith_project.billing.id
url = "https://hooks.slack.com/services/..."
events = ["mass_patch.completed", "drift.detected", "approval.requested"]
secret = var.slack_webhook_secret
}

Workflow rapide

  1. Generer une API key admin sur Auralith. La stocker dans TF_VAR_auralith_api_key ou un secret manager.
  2. terraform init pour telecharger le provider.
  3. Definir vos resources dans des fichiers .tf.
  4. terraform plan pour voir le diff.
  5. terraform apply.

Concepts cles

  • State : Terraform stocke l'etat. Recommande : backend remote (S3, GCS, Terraform Cloud) avec lock.
  • Drift : terraform plan detecte les divergences entre .tf et l'etat Auralith reel. Si quelqu'un modifie via UI, vous le voyez.
  • Importable : terraform import auralith_project.foo <project_id> pour rapatrier une ressource existante.

Pieges courants

  • Secrets en clair dans .tfstate : utiliser un backend chiffre (S3 + KMS) ou referencer via secret_provider au lieu de stocker password en clair dans Terraform.
  • Cycles : eviter de creer des resources qui se referencent mutuellement (project -> webhook -> project). Lineaire fonctionne mieux.
  • Provider en alpha : breaking changes possibles avant 1.0. Pin la version exacte en prod.

Lien repo

Source du provider : gitlab.com/fullchelh/auralith

Voir aussi