Atlas Scripts
mask
A reusable, named mask. Define columns (globs allowed) and a method once at the top level, then apply it via use = [mask.<name>] from any query or script.
mask "pii" {
columns = ["ssn", "*email*"]
method = HASH
}
mask attributes
| Name and description | Required | Value |
|---|---|---|
| false | string |
Output columns to mask, matched case-sensitively; an entry with | false | List of strings |
| false | int |
| false | int |
| false | int |
| false | string |
Masking method ( | false |
|
| false | string |
| false | string |
| false | string |
mask constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., mask "name" ) | true |
| Repeatable | true |
script exec
Runs a sequence of condition, assert, check, exec, query, and http blocks as a program against the connected database. Blocks execute in their textual order; a failing assert/check/exec aborts the script (and rolls back when on_error = ROLLBACK), while an unmet condition stops it gracefully. A query binds its result for later steps as query.<name>.rows[*].<col>, an http step its decoded response as http.<name>.<field>.
script.exec attributes
| Name and description | Required | Value |
|---|---|---|
Free-form description; surfaced in audit logs. | false | string |
script.exec blocks
script.assert
An assert runs inside the script's session and asserts a boolean SQL condition. A failing assertion aborts the script (and rolls back when tx.on_error = ROLLBACK).
assert "is_active" {
sql = "select status = 'active' from users where id = ?"
args = [var.id]
}
sql must return exactly one row, one boolean (or 1/0) column. A truthy value passes; falsy or NULL fails.
script.assert attributes
| Name and description | Required | Value |
|---|---|---|
Positional values bound to placeholders in | false | Positional bind values can be one of: |
Message returned to the user when the assertion fails. | false | string |
SQL query whose single boolean (or 1/0) result is asserted. | true | string |
script.assert constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
script.break
Stop the run when its condition is true - committing the work done so far in a loop iteration, rolling it back in an exec script with tx.mode = AUTO.
break "disk_pressure" {
sql = "select pg_database_size(current_database()) > 5e11"
}
break "nothing_to_do" {
expr = length(query.batch.rows) == 0
}
script.break attributes
| Name and description | Required | Value |
|---|---|---|
Positional values bound to placeholders in | false | Positional bind values can be one of: |
Boolean expression evaluated in-process, e.g. | false | Boolean expression over the scope can be one of: |
Boolean SQL; when true (truthy), the run stops. | false | string |
script.break constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
| Mutually exclusive sets | [sql, expr], [expr, args] |
| One of required sets | [sql, expr] |
script.check
A check runs a SQL query and compares its formatted output to an expected value or pattern - same shape as the exec block in atlas test.
check "user_count" {
sql = "select count(*) from users"
output = "1"
}
script.check attributes
| Name and description | Required | Value |
|---|---|---|
Positional values bound to placeholders in | false | Positional bind values can be one of: |
Message returned to the user when the check fails. | false | string |
Serialization format for the query output ( | false |
|
Regular expression the output must match. | false | string |
Expected output, compared after trimming surrounding whitespace. | false | string |
SQL query whose output is compared. | true | string |
script.check constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
| Mutually exclusive sets | [output, match] |
script.condition
A guard evaluated in textual order with the other steps. When its boolean SQL is not satisfied, the script stops gracefully at that point - committing the work done so far - without reporting a failure.
condition "user_exists" {
sql = "select count(*) > 0 from users where id = ?"
args = [var.id]
}
sql must return exactly one row, one boolean (or 1/0) column. A truthy value lets the program continue; falsy or NULL stops it gracefully.
script.condition attributes
| Name and description | Required | Value |
|---|---|---|
Positional values bound to placeholders in | false | Positional bind values can be one of: |
SQL query whose single boolean (or 1/0) result is the guard. | true | string |
script.condition constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., script.condition "name" ) | true |
| Repeatable | true |
script.exec
The mutation to run. The name label is optional and surfaces in logs.
script.exec attributes
| Name and description | Required | Value |
|---|---|---|
Positional values bound to placeholders in | false | Positional bind values can be one of: |
Expected number of rows affected by | false | int |
SQL statement (or batch) to execute. | true | string |
script.exec constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
script.http
Call an external HTTP endpoint (e.g. a service's deletion API that also cleans up blob storage). url/headers/body may interpolate scope like query.<name>.rows[*].id. A fired request cannot be rolled back: requires tx { mode = MANUAL } in a loop and tx { mode = NONE } in an exec script.
http "del" {
url = var.deletion_endpoint
method = POST
body = jsonencode({ ids = query.batch.rows[*].id })
response = object({ data = object({ deleteUsers = object({ deleted = number }) }) })
}
script.http attributes
| Name and description | Required | Value |
|---|---|---|
The request body as a string. | false | string |
Certificate Authority (CA) in PEM (RFC 1421) format. | false | string |
Client certificate in PEM (RFC 1421) format. | false | string |
Client key in PEM (RFC 1421) format. | false | string |
Expected HTTP status code; a mismatch fails the step. | false | int |
A map of request header field names and values. | false | map |
Disables verification of the server's certificate chain and hostname. Defaults to | false | bool |
HTTP method ( | false |
|
The request timeout in milliseconds. | false | int |
Expected JSON response shape as a type, e.g. | false | HCL type ( |
The URL for the request. Supported schemes are | true | string |
script.http blocks
script.http.check
Assert a boolean condition over the decoded response; a false or null result fails the step (and the loop, per on_error). No SQL - evaluated in-process.
check {
condition = length(http.del.errors) == 0
error_message = "deletion service returned errors"
}
script.http.check attributes
| Name and description | Required | Value |
|---|---|---|
Boolean expression over the response, e.g. | true | Boolean condition over the response can be one of:
|
Message returned to the user when the condition fails. | false | string |
script.http.check constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
script.http.retry
Retry request configuration. By default there are no retries. Configuring this block will result in retries if an error is returned by the client (e.g., connection errors) or if a 5xx-range (except 501) status code is received.
script.http.retry attributes
| Name and description | Required | Value |
|---|---|---|
The number of times the request is to be retried. For example, if 2 is specified, the request will be tried a maximum of 3 times. | false | int |
The maximum delay between retry requests in milliseconds. | false | int |
The minimum delay between retry requests in milliseconds. | false | int |
script.http constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
| Mutually exclusive sets | [ca_cert_pem, insecure] |
script.output
Emit a line of script output, e.g. "archived ${length(query.dormant.rows)} users". Unlike log (diagnostics), output is part of the script's result and is printed even by a quiet logger.
script.output attributes
| Name and description | Required | Value |
|---|---|---|
The line to emit; may interpolate scope values, e.g. | true | string |
script.output constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
script.query
A read whose result later steps reference as query.<name>.rows[*].<col> (a list), .rows[N].<col> (one row), or length(query.<name>.rows).
query "batch" {
sql = "SELECT id, email FROM staging WHERE batch = ? ORDER BY id"
args = [iterator.range.from]
rows { id = int email = string }
}
script.query attributes
| Name and description | Required | Value |
|---|---|---|
Positional values bound to placeholders in | false | Positional bind values can be one of: |
SQL query to run. Atlas binds | true | string |
script.query blocks
script.query.rows
The result columns, declared as typed columns (name = <type>). Atlas reads only these columns, by name, and exposes them as query.<name>.rows[*].<col>.
script.query.rows constraints
| Constraint | Value |
|---|---|
| Required | true |
| Require Name | false |
| Allow unknown attributes | true |
script.query constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
script.tx
Transactional envelope for the script.
script.tx attributes
| Name and description | Required | Value |
|---|---|---|
Transaction mode. | false |
|
Behavior when the script errors. | false |
|
script.exec constraints
| Constraint | Value |
|---|---|
| Required | false |
| Repeatable | true |
script loop
Batched/repeated loop: pre-loop condition gates, one iterator + one do body, post-loop assert/check, and an optional policy block (tx/schedule/ramp).
script.loop attributes
| Name and description | Required | Value |
|---|---|---|
Free-form description; surfaced in audit logs. | false | string |
script.loop blocks
script.assert
An assert runs inside the script's session and asserts a boolean SQL condition. A failing assertion aborts the script (and rolls back when tx.on_error = ROLLBACK).
assert "is_active" {
sql = "select status = 'active' from users where id = ?"
args = [var.id]
}
sql must return exactly one row, one boolean (or 1/0) column. A truthy value passes; falsy or NULL fails.
script.assert attributes
| Name and description | Required | Value |
|---|---|---|
Positional values bound to placeholders in | false | Any value |
Message returned to the user when the assertion fails. | false | string |
SQL query whose single boolean (or 1/0) result is asserted. | true | string |
script.assert constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
script.check
A check runs a SQL query and compares its formatted output to an expected value or pattern - same shape as the exec block in atlas test.
check "user_count" {
sql = "select count(*) from users"
output = "1"
}
script.check attributes
| Name and description | Required | Value |
|---|---|---|
Positional values bound to placeholders in | false | Any value |
Message returned to the user when the check fails. | false | string |
Serialization format for the query output ( | false |
|
Regular expression the output must match. | false | string |
Expected output, compared after trimming surrounding whitespace. | false | string |
SQL query whose output is compared. | true | string |
script.check constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
| Mutually exclusive sets | [output, match] |
script.condition
A guard evaluated in textual order with the other steps. When its boolean SQL is not satisfied, the script stops gracefully at that point - committing the work done so far - without reporting a failure.
condition "user_exists" {
sql = "select count(*) > 0 from users where id = ?"
args = [var.id]
}
sql must return exactly one row, one boolean (or 1/0) column. A truthy value lets the program continue; falsy or NULL stops it gracefully.
script.condition attributes
| Name and description | Required | Value |
|---|---|---|
Positional values bound to placeholders in | false | Any value |
SQL query whose single boolean (or 1/0) result is the guard. | true | string |
script.condition constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., script.condition "name" ) | true |
| Repeatable | true |
script.do
The per-iteration body. Same shape as an exec script; args may reference iterator.<mode>.* (e.g. batch). With tx.mode = MANUAL, wrap atomic statements in tx { } blocks.
script.do attributes
| Name and description | Required | Value |
|---|---|---|
On a failing iteration: | false |
|
script.do blocks
script.do.assert
An assert runs inside the script's session and asserts a boolean SQL condition. A failing assertion aborts the script (and rolls back when tx.on_error = ROLLBACK).
assert "is_active" {
sql = "select status = 'active' from users where id = ?"
args = [var.id]
}
sql must return exactly one row, one boolean (or 1/0) column. A truthy value passes; falsy or NULL fails.
script.do.assert attributes
| Name and description | Required | Value |
|---|---|---|
Positional values bound to placeholders in | false | Positional bind values can be one of:
|
Message returned to the user when the assertion fails. | false | string |
SQL query whose single boolean (or 1/0) result is asserted. | true | string |
script.do.assert constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
script.do.break
Stop the run when its condition is true - committing the work done so far in a loop iteration, rolling it back in an exec script with tx.mode = AUTO.
break "disk_pressure" {
sql = "select pg_database_size(current_database()) > 5e11"
}
break "nothing_to_do" {
expr = length(query.batch.rows) == 0
}
script.do.break attributes
| Name and description | Required | Value |
|---|---|---|
Positional values bound to placeholders in | false | Positional bind values can be one of:
|
Boolean expression evaluated in-process, e.g. | false | Boolean expression over the scope can be one of:
|
Boolean SQL; when true (truthy), the run stops. | false | string |
script.do.break constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
| Mutually exclusive sets | [sql, expr], [expr, args] |
| One of required sets | [sql, expr] |
script.do.check
A check runs a SQL query and compares its formatted output to an expected value or pattern - same shape as the exec block in atlas test.
check "user_count" {
sql = "select count(*) from users"
output = "1"
}
script.do.check attributes
| Name and description | Required | Value |
|---|---|---|
Positional values bound to placeholders in | false | Positional bind values can be one of:
|
Message returned to the user when the check fails. | false | string |
Serialization format for the query output ( | false |
|
Regular expression the output must match. | false | string |
Expected output, compared after trimming surrounding whitespace. | false | string |
SQL query whose output is compared. | true | string |