Home

Awesome

Atlas Terraform Provider

Twitter Discord

<p> <a href="https://atlasgo.io" target="_blank"> <img alt="image" src="https://github.com/ariga/atlas/assets/7413593/2e27cb81-bad6-491a-8d9c-20920995a186"> </a> </p>

Atlas is a language-agnostic tool for managing and migrating database schemas using modern DevOps principles. It offers two workflows:

Installation

terraform {
  required_providers {
    atlas = {
      source  = "ariga/atlas"
      version = "~> 0.6.1"
    }
  }
}
provider "atlas" {
  # Use MySQL 8 docker image as the dev database.
  dev_url = "docker://mysql/8"
}

Quick Start

1. To create a schema for your database, first install atlas

2. Then, inspect the schema of the database:

atlas schema inspect -u "mysql://root:pass@localhost:3306/example" > schema.hcl

3. Finally, configure the terraform resource to apply the state to your database:

data "atlas_schema" "my_schema" {
  src     = "file://${abspath("./schema.hcl")}"
  dev_url = "mysql://root:pass@localhost:3307/example"
}

resource "atlas_schema" "example_db" {
  hcl     = data.atlas_schema.my_schema.hcl
  url     = "mysql://root:pass@localhost:3306/example"
  dev_url = "mysql://root:pass@localhost:3307/example"
}

For more advanced examples, check out the examples folder.

Docs

Supported databases:

MySQL, MariaDB, PostgresSQL, SQLite, TiDB, CockroachDB, SQL Server, ClickHouse, Redshift.