Skip to main content

Atlas Configuration

atlas

The atlas is an optional block for configuring Atlas login credentials.

atlas {
cloud {
org = "org-name"
}
}

atlas blocks

atlas.cloud

atlas.cloud attributes
Name and descriptionRequiredValue

org

The org attribute specifies the organization to log in to. If Atlas executes using atlas.hcl without logging in to the specified organization, the command will be aborted.

falsestring
tokenfalsestring
atlas.cloud constraints
ConstraintValue
Requiredtrue
Require Namefalse
One of required sets[org, token]

data aws_rds_token

The aws_rds_token data source generates a short-lived token for an AWS RDS database using IAM Authentication.

data "aws_rds_token" "db" {
region = "us-east-1"
endpoint = local.endpoint
username = local.user
}

data.aws_rds_token attributes

NameRequiredValue
endpointtruestring
regionfalsestring
usernametruestring

data composite_schema

The composite_schema data source allows the composition of multiple Atlas schemas into a unified schema graph.

data "composite_schema" "app" {
schema "inventory" {
url = data.external_schema.sqlalchemy.url
}
schema "graph" {
url = "ent://ent/schema"
}
...
}

data.composite_schema blocks

data.schema

data.schema attributes
NameRequiredValue
urltrue

Composite_schema url can be one of:

  1. Object reference
  2. string
data.schema constraints
ConstraintValue
Requiredtrue
Require Namefalse
Repeatabletrue

data external

The external allows the execution of an external program and uses its output in the project.

data "external" "dot_env" {
program = [
"npm",
"run",
"load-env.js"
]
}

data.external attributes

NameRequiredValue
programtrue

List of strings

working_dirfalsestring

data external_schema

The external_schema data source allows the import of an SQL schema from an external program into Atlas' desired state.

data "external_schema" "graph" {
program = [
"npm",
"run",
"generate-schema"
]
}

data.external_schema attributes

NameRequiredValue
programtrue

List of strings

working_dirfalsestring

data gcp_cloudsql_token

The gcp_cloudsql_token data source generates a short-lived token for an GCP CloudSQL database using IAM Authentication.

data "gcp_cloudsql_token" "db" {}

data.gcp_cloudsql_token attributes

NameRequiredValue
regionfalsestring

data hcl_schema

The hcl_schema data source allows the loading of an Atlas HCL schema from a file or directory, with optional variables.

data "hcl_schema" "app" {
path = "schema.hcl"
vars = {
tenant = var.tenant
}
}

data.hcl_schema attributes

NameRequiredValue
pathfalsestring
pathsfalse

List of strings

varsfalsemap

data remote_dir

The remote_dir data source reads the state of a migration directory from Atlas Cloud.

data "remote_dir" "migrations" {
name = "myapp"
}

data.remote_dir attributes

NameRequiredValue
nametruestring
tagfalsestring

data remote_schema

data.remote_schema attributes

NameRequiredValue
nametruestring
tagfalsestring
versionfalsestring

data runtimevar

The runtimevar data source allows fetching runtime variables from a remote source.

data.runtimevar attributes

NameRequiredValue
urltruestring

data sql

The sql data source allows executing SQL queries and using their result in the project.

data "sql" "tenants" {
url = var.url
query = "..."
args = [var.pattern]
}

data.sql attributes

NameRequiredValue
argsfalse

Any value

querytruestring
urltruestring

data template_dir

The template_dir data source renders a migration directory from a template directory.

data "template_dir" "app" {
path = var.path
vars = {
Key1 = "value1"
Key2 = "value2"
}
}

data.template_dir attributes

NameRequiredValue
pathtruestring
varsfalsemap

dev clickhouse

dev.clickhouse attributes

NameRequiredValue
baselinefalsestring
urltruestring

dev.clickhouse blocks

dev.connection

The connection block defines the connection configuration for the dev-database.

dev "postgres" "postgis" {
...
connection {
max_open = 1
max_idle = 1
max_lifetime = "30s"
max_idle_time = "30s"
}
}
dev.connection attributes
NameRequiredValue
max_idlefalseint
max_idle_timefalsestring
max_lifetimefalsestring
max_openfalseint

dev mariadb

dev.mariadb attributes

NameRequiredValue
baselinefalsestring
urltruestring

dev.mariadb blocks

dev.connection

The connection block defines the connection configuration for the dev-database.

dev "postgres" "postgis" {
...
connection {
max_open = 1
max_idle = 1
max_lifetime = "30s"
max_idle_time = "30s"
}
}
dev.connection attributes
NameRequiredValue
max_idlefalseint
max_idle_timefalsestring
max_lifetimefalsestring
max_openfalseint

dev mysql

dev.mysql attributes

NameRequiredValue
baselinefalsestring
urltruestring

dev.mysql blocks

dev.connection

The connection block defines the connection configuration for the dev-database.

dev "postgres" "postgis" {
...
connection {
max_open = 1
max_idle = 1
max_lifetime = "30s"
max_idle_time = "30s"
}
}
dev.connection attributes
NameRequiredValue
max_idlefalseint
max_idle_timefalsestring
max_lifetimefalsestring
max_openfalseint

dev postgres

dev.postgres attributes

NameRequiredValue
baselinefalsestring
urltruestring

dev.postgres blocks

dev.connection

The connection block defines the connection configuration for the dev-database.

dev "postgres" "postgis" {
...
connection {
max_open = 1
max_idle = 1
max_lifetime = "30s"
max_idle_time = "30s"
}
}
dev.connection attributes
NameRequiredValue
max_idlefalseint
max_idle_timefalsestring
max_lifetimefalsestring
max_openfalseint

dev redshift

dev.redshift attributes

NameRequiredValue
baselinefalsestring
urltruestring

dev.redshift blocks

dev.connection

The connection block defines the connection configuration for the dev-database.

dev "postgres" "postgis" {
...
connection {
max_open = 1
max_idle = 1
max_lifetime = "30s"
max_idle_time = "30s"
}
}
dev.connection attributes
NameRequiredValue
max_idlefalseint
max_idle_timefalsestring
max_lifetimefalsestring
max_openfalseint

dev sqlserver

dev.sqlserver attributes

NameRequiredValue
baselinefalsestring
urltruestring

dev.sqlserver blocks

dev.connection

The connection block defines the connection configuration for the dev-database.

dev "postgres" "postgis" {
...
connection {
max_open = 1
max_idle = 1
max_lifetime = "30s"
max_idle_time = "30s"
}
}
dev.connection attributes
NameRequiredValue
max_idlefalseint
max_idle_timefalsestring
max_lifetimefalsestring
max_openfalseint

diff

The diff block defines the diffing configuration

diff {
concurrent_index {
add = true
drop = true
}
}

diff blocks

diff.concurrent_index

diff.concurrent_index attributes
NameRequiredValue
addfalsebool
createfalsebool
dropfalsebool

diff.skip

diff.skip attributes
NameRequiredValue
add_columnfalsebool
add_foreign_keyfalsebool
add_funcfalsebool
add_indexfalsebool
add_procfalsebool
add_schemafalsebool
add_tablefalsebool
add_triggerfalsebool
add_viewfalsebool
drop_columnfalsebool
drop_foreign_keyfalsebool
drop_funcfalsebool
drop_indexfalsebool
drop_procfalsebool
drop_schemafalsebool
drop_tablefalsebool
drop_triggerfalsebool
drop_viewfalsebool
modify_columnfalsebool
modify_foreign_keyfalsebool
modify_funcfalsebool
modify_indexfalsebool
modify_procfalsebool
modify_schemafalsebool
modify_tablefalsebool
modify_triggerfalsebool
modify_viewfalsebool
rename_funcfalsebool
rename_procfalsebool
rename_tablefalsebool
rename_triggerfalsebool
rename_viewfalsebool

docker clickhouse

docker.clickhouse attributes

Name and descriptionRequiredValue
baselinefalsestring
envfalse

List of strings

imagetruestring

init

The init attribute specifies the initialization script for the Docker-based database created in Atlas.

docker "mysql" "dev" {
image = "mysql:8.4"
init = <<-SQL
SET GLOBAL log_bin_trust_function_creators=true;
SET GLOBAL restrict_fk_on_non_standard_key=false;
SET GLOBAL sql_mode := REPLACE(@@sql_mode, 'NO_ZERO_DATE', '');
SQL
}
falsestring
schemafalsestring

docker.clickhouse blocks

docker.build

The build block defines the build configuration for the Docker image. The given image is built using the provided Dockerfile and context.

docker "postgres" "pg-vn" {
image = "postgres:15-vn"
build {
context = "."
dockerfile = "locale.Dockerfile"
args = {
LOCALE = "vi-VN"
}
}
}
docker.build attributes
NameRequiredValue
argsfalsemap
contexttruestring
dockerfilefalsestring
platformfalse

List of strings

targetfalsestring

docker.connection

The connection block defines the connection configuration for the Docker-based database created in Atlas.

docker "postgres" "dev" {
...
connection {
max_open = 1
max_idle = 1
max_lifetime = "30s"
max_idle_time = "30s"
}
}
docker.connection attributes
NameRequiredValue
max_idlefalseint
max_idle_timefalsestring
max_lifetimefalsestring
max_openfalseint

docker mariadb

docker.mariadb attributes

Name and descriptionRequiredValue
baselinefalsestring
envfalse

List of strings

imagetruestring

init

The init attribute specifies the initialization script for the Docker-based database created in Atlas.

docker "mysql" "dev" {
image = "mysql:8.4"
init = <<-SQL
SET GLOBAL log_bin_trust_function_creators=true;
SET GLOBAL restrict_fk_on_non_standard_key=false;
SET GLOBAL sql_mode := REPLACE(@@sql_mode, 'NO_ZERO_DATE', '');
SQL
}
falsestring
schemafalsestring

docker.mariadb blocks

docker.build

The build block defines the build configuration for the Docker image. The given image is built using the provided Dockerfile and context.

docker "postgres" "pg-vn" {
image = "postgres:15-vn"
build {
context = "."
dockerfile = "locale.Dockerfile"
args = {
LOCALE = "vi-VN"
}
}
}
docker.build attributes
NameRequiredValue
argsfalsemap
contexttruestring
dockerfilefalsestring
platformfalse

List of strings

targetfalsestring

docker.connection

The connection block defines the connection configuration for the Docker-based database created in Atlas.

docker "postgres" "dev" {
...
connection {
max_open = 1
max_idle = 1
max_lifetime = "30s"
max_idle_time = "30s"
}
}
docker.connection attributes
NameRequiredValue
max_idlefalseint
max_idle_timefalsestring
max_lifetimefalsestring
max_openfalseint

docker mysql

docker.mysql attributes

Name and descriptionRequiredValue
baselinefalsestring
envfalse

List of strings

imagetruestring

init

The init attribute specifies the initialization script for the Docker-based database created in Atlas.

docker "mysql" "dev" {
image = "mysql:8.4"
init = <<-SQL
SET GLOBAL log_bin_trust_function_creators=true;
SET GLOBAL restrict_fk_on_non_standard_key=false;
SET GLOBAL sql_mode := REPLACE(@@sql_mode, 'NO_ZERO_DATE', '');
SQL
}
falsestring
schemafalsestring

docker.mysql blocks

docker.build

The build block defines the build configuration for the Docker image. The given image is built using the provided Dockerfile and context.

docker "postgres" "pg-vn" {
image = "postgres:15-vn"
build {
context = "."
dockerfile = "locale.Dockerfile"
args = {
LOCALE = "vi-VN"
}
}
}
docker.build attributes
NameRequiredValue
argsfalsemap
contexttruestring
dockerfilefalsestring
platformfalse

List of strings

targetfalsestring

docker.connection

The connection block defines the connection configuration for the Docker-based database created in Atlas.

docker "postgres" "dev" {
...
connection {
max_open = 1
max_idle = 1
max_lifetime = "30s"
max_idle_time = "30s"
}
}
docker.connection attributes
NameRequiredValue
max_idlefalseint
max_idle_timefalsestring
max_lifetimefalsestring
max_openfalseint

docker postgres

docker.postgres attributes

Name and descriptionRequiredValue
baselinefalsestring
databasefalsestring
envfalse

List of strings

imagetruestring

init

The init attribute specifies the initialization script for the Docker-based database created in Atlas.

docker "mysql" "dev" {
image = "mysql:8.4"
init = <<-SQL
SET GLOBAL log_bin_trust_function_creators=true;
SET GLOBAL restrict_fk_on_non_standard_key=false;
SET GLOBAL sql_mode := REPLACE(@@sql_mode, 'NO_ZERO_DATE', '');
SQL
}
falsestring
schemafalsestring

docker.postgres blocks

docker.build

The build block defines the build configuration for the Docker image. The given image is built using the provided Dockerfile and context.

docker "postgres" "pg-vn" {
image = "postgres:15-vn"
build {
context = "."
dockerfile = "locale.Dockerfile"
args = {
LOCALE = "vi-VN"
}
}
}
docker.build attributes
NameRequiredValue
argsfalsemap
contexttruestring
dockerfilefalsestring
platformfalse

List of strings

targetfalsestring

docker.connection

The connection block defines the connection configuration for the Docker-based database created in Atlas.

docker "postgres" "dev" {
...
connection {
max_open = 1
max_idle = 1
max_lifetime = "30s"
max_idle_time = "30s"
}
}
docker.connection attributes
NameRequiredValue
max_idlefalseint
max_idle_timefalsestring
max_lifetimefalsestring
max_openfalseint

docker sqlserver

docker.sqlserver attributes

Name and descriptionRequiredValue
baselinefalsestring
collatefalsestring
databasefalsestring
envfalse

List of strings

imagetruestring

init

The init attribute specifies the initialization script for the Docker-based database created in Atlas.

docker "mysql" "dev" {
image = "mysql:8.4"
init = <<-SQL
SET GLOBAL log_bin_trust_function_creators=true;
SET GLOBAL restrict_fk_on_non_standard_key=false;
SET GLOBAL sql_mode := REPLACE(@@sql_mode, 'NO_ZERO_DATE', '');
SQL
}
falsestring
modefalse

enum (database, schema)

schemafalsestring

docker.sqlserver blocks

docker.build

The build block defines the build configuration for the Docker image. The given image is built using the provided Dockerfile and context.

docker "postgres" "pg-vn" {
image = "postgres:15-vn"
build {
context = "."
dockerfile = "locale.Dockerfile"
args = {
LOCALE = "vi-VN"
}
}
}
docker.build attributes
NameRequiredValue
argsfalsemap
contexttruestring
dockerfilefalsestring
platformfalse

List of strings

targetfalsestring

docker.connection

The connection block defines the connection configuration for the Docker-based database created in Atlas.

docker "postgres" "dev" {
...
connection {
max_open = 1
max_idle = 1
max_lifetime = "30s"
max_idle_time = "30s"
}
}
docker.connection attributes
NameRequiredValue
max_idlefalseint
max_idle_timefalsestring
max_lifetimefalsestring
max_openfalseint

env

The env block describes an environment block that can be selected by using the --env flag.

env attributes

NameRequiredValue
devfalsestring
excludefalse

List of strings

namefalsestring
schemasfalse

List of strings

srcfalse

Schema source can be one of:

  1. Object reference
  2. string
  3. List of strings
urlfalsestring

env blocks

env.diff

The diff block defines the diffing configuration

diff {
concurrent_index {
add = true
drop = true
}
}
env.diff blocks

env.diff.concurrent_index

env.diff.concurrent_index attributes
NameRequiredValue
addfalsebool
createfalsebool
dropfalsebool

env.diff.skip

env.diff.skip attributes
NameRequiredValue
add_columnfalsebool
add_foreign_keyfalsebool
add_funcfalsebool
add_indexfalsebool
add_procfalsebool
add_schemafalsebool
add_tablefalsebool
add_triggerfalsebool
add_viewfalsebool
drop_columnfalsebool
drop_foreign_keyfalsebool
drop_funcfalsebool
drop_indexfalsebool
drop_procfalsebool
drop_schemafalsebool
drop_tablefalsebool
drop_triggerfalsebool
drop_viewfalsebool
modify_columnfalsebool
modify_foreign_keyfalsebool
modify_funcfalsebool
modify_indexfalsebool
modify_procfalsebool
modify_schemafalsebool
modify_tablefalsebool
modify_triggerfalsebool
modify_viewfalsebool
rename_funcfalsebool
rename_procfalsebool
rename_tablefalsebool
rename_triggerfalsebool
rename_viewfalsebool

env.format

The format block defines the output format of the different commands

format {
migrate {
diff = "{{ sql . \" \" }}"
}
}
env.format blocks

env.format.migrate

env.format.migrate attributes
NameRequiredValue
applyfalsestring
difffalsestring
downfalsestring
lintfalsestring
statusfalsestring

env.format.schema

env.format.schema attributes
NameRequiredValue
applyfalsestring
difffalsestring
inspectfalsestring

env.lint

The lint block defines the linting configuration

lint {
destructive {
error = false
}
concurrent_index {
error = true
}
}
env.lint attributes
NameRequiredValue
formatfalsestring
latestfalseint
logfalsestring
reviewfalse

enum (ALWAYS, WARNING, ERROR)

env.lint blocks

env.lint.concurrent_index

env.lint.concurrent_index attributes
NameRequiredValue
check_createfalsebool
check_dropfalsebool
check_txmodefalsebool
errorfalsebool

env.lint.condrop

env.lint.condrop attributes
NameRequiredValue
errorfalsebool

env.lint.data_depend

env.lint.data_depend attributes
NameRequiredValue
errorfalsebool

env.lint.destructive

env.lint.destructive attributes
NameRequiredValue
errorfalsebool

env.lint.git

env.lint.git attributes
NameRequiredValue
basefalsestring
dirfalsestring

env.lint.incompatible

env.lint.incompatible attributes
NameRequiredValue
errorfalsebool

env.lint.naming

env.lint.naming attributes
NameRequiredValue
errorfalsebool
matchfalsestring
messagefalsestring
env.lint.naming blocks

env.lint.naming.check

env.lint.naming.check attributes
NameRequiredValue
matchfalsestring
messagefalsestring

env.lint.naming.column

env.lint.naming.column attributes
NameRequiredValue
matchfalsestring
messagefalsestring

env.lint.naming.foreign_key

env.lint.naming.foreign_key attributes
NameRequiredValue
matchfalsestring
messagefalsestring

env.lint.naming.index

env.lint.naming.index attributes
NameRequiredValue
matchfalsestring
messagefalsestring

env.lint.naming.schema

env.lint.naming.schema attributes
NameRequiredValue
matchfalsestring
messagefalsestring

env.lint.naming.table

env.lint.naming.table attributes
NameRequiredValue
matchfalsestring
messagefalsestring

env.lint.non_linear

env.lint.non_linear attributes
NameRequiredValue
errorfalsebool

env.lint.rule.hcl

env.lint.rule.hcl attributes
NameRequiredValue
srctrue

List of strings

varsfalsemap
env.lint constraints
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[latest, git], [log, format]

env.log

Use the format block instead

env.log blocks

env.log.migrate

env.log.migrate attributes
NameRequiredValue
applyfalsestring
difffalsestring
downfalsestring
lintfalsestring
statusfalsestring

env.log.schema

env.log.schema attributes
NameRequiredValue
applyfalsestring
difffalsestring
inspectfalsestring

env.migration

The migration block defines the migration configuration

migration {
dir = "file://migrations"
repo {
name = "app"
}
}
env.migration attributes
NameRequiredValue
baselinefalsestring
dirfalsestring
excludefalse

List of strings

exec_orderfalse

enum (LINEAR, linear, LINEAR_SKIP, linear-skip, NON_LINEAR, non-linear)

formatfalse

Migration format can be one of:

  1. enum (atlas, golang-migrate, goose, flyway, liquibase, dbmate)
  2. string
lock_timeoutfalsestring
revisions_schemafalsestring
env.migration blocks

env.migration.repo

The repository configuration for the migrations directory in the registry

repo {
name = "app"
}
env.migration.repo attributes
NameRequiredValue
nametruestring

env.schema

The configuration for the desired schema

schema {
src = "file://schema.hcl"
repo {
name = "app"
}
}
env.schema attributes
NameRequiredValue
srctrue

Schema source can be one of:

  1. Object reference
  2. string
  3. List of strings
env.schema blocks

env.schema.repo

The repository configuration for the desired schema in the registry

repo {
name = "app"
}
env.schema.repo attributes
NameRequiredValue
nametruestring

env.test

The test block defines the testing configuration

test {
schema {
src = ["schema.test.hcl"]
vars = {
seed_file = "filename.sql"
variable2 = var.name
variable3 = data.external.value
}
}
}
env.test blocks

env.test.migrate

env.test.migrate attributes
NameRequiredValue
srctrue

List of strings

varsfalsemap

env.test.schema

env.test.schema attributes
NameRequiredValue
srctrue

List of strings

varsfalsemap

env constraints

ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Allow unknown attributestrue
Mutually exclusive sets[src, schema]

hook sql

The hook "sql" "name" block defines an SQL hook configuration.

hook "sql" "timeout" {
transaction {
after_begin = [
"SET statement_timeout TO '50ms'",
]
}
}

hook.sql attributes

NameRequiredValue
skip_errorsfalsebool

hook.sql blocks

hook.transaction

hook.transaction attributes
NameRequiredValue
after_beginfalse

List of strings

before_commitfalse

List of strings

before_rollbackfalse

List of strings

lint

The lint block defines the linting configuration

lint {
destructive {
error = false
}
concurrent_index {
error = true
}
}

lint attributes

NameRequiredValue
formatfalsestring
latestfalseint
logfalsestring
reviewfalse

enum (ALWAYS, WARNING, ERROR)

lint blocks

lint.concurrent_index

lint.concurrent_index attributes
NameRequiredValue
check_createfalsebool
check_dropfalsebool
check_txmodefalsebool
errorfalsebool

lint.condrop

lint.condrop attributes
NameRequiredValue
errorfalsebool

lint.data_depend

lint.data_depend attributes
NameRequiredValue
errorfalsebool

lint.destructive

lint.destructive attributes
NameRequiredValue
errorfalsebool

lint.git

lint.git attributes
NameRequiredValue
basefalsestring
dirfalsestring

lint.incompatible

lint.incompatible attributes
NameRequiredValue
errorfalsebool

lint.naming

lint.naming attributes
NameRequiredValue
errorfalsebool
matchfalsestring
messagefalsestring
lint.naming blocks

lint.naming.check

lint.naming.check attributes
NameRequiredValue
matchfalsestring
messagefalsestring

lint.naming.column

lint.naming.column attributes
NameRequiredValue
matchfalsestring
messagefalsestring

lint.naming.foreign_key

lint.naming.foreign_key attributes
NameRequiredValue
matchfalsestring
messagefalsestring

lint.naming.index

lint.naming.index attributes
NameRequiredValue
matchfalsestring
messagefalsestring

lint.naming.schema

lint.naming.schema attributes
NameRequiredValue
matchfalsestring
messagefalsestring

lint.naming.table

lint.naming.table attributes
NameRequiredValue
matchfalsestring
messagefalsestring

lint.non_linear

lint.non_linear attributes
NameRequiredValue
errorfalsebool

lint.rule.hcl

lint.rule.hcl attributes
NameRequiredValue
srctrue

List of strings

varsfalsemap

lint constraints

ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[latest, git], [log, format]

test

The test block defines the testing configuration

test {
schema {
src = ["schema.test.hcl"]
vars = {
seed_file = "filename.sql"
variable2 = var.name
variable3 = data.external.value
}
}
}

test blocks

test.migrate

test.migrate attributes
NameRequiredValue
srctrue

List of strings

varsfalsemap

test.schema

test.schema attributes
NameRequiredValue
srctrue

List of strings

varsfalsemap