Data PlatformZoom level 1
Deployment: from a fresh checkout to a first run, with a gate at every stage
After you check out the code, deployment is fifteen steps. Some are automated by Terraform, the asset bundle and CI. Some are manual and will stay manual: signing in, accepting an account, putting a secret's value in. Between the steps there is a gate: a script that checks, without changing anything, that the step really happened. You do not start a step until the gate before it passes.
The gates
| Gate | What it proves | Run it with |
|---|---|---|
| G0 | tools, the catalog checkout, no keys in git | python3 scripts/preflight.py --gate G0 |
| G1 | access: AWS, Databricks, GitHub (and which services a policy denies) | --gate G1 --databricks-profile NAME --aws-profile NAME |
| G2 | after the account setup: state bucket and CI roles exist | --gate G2 |
| G3 | after the infrastructure deploy: buckets, keys, secrets, catalogs, volume, external locations | --gate G3 --env dev |
| G4 | after the metadata store setup: the Lakebase database exists | --gate G4 --env dev |
| G5 | after the bundle deploy: the jobs exist and validate | --gate G5 --env dev |
| G6 | after the first run: a report is in the volume | --gate G6 --env dev |
All gates are one script, scripts/preflight.py. It only lists and describes, so it is safe to run anywhere, any number of times. A failed check prints the step that fixes it. A check that depends on a failed one is skipped, so you see the first real problem and not a pile of follow-on errors. Optional things (Lakebase, a SQL warehouse) are warnings, not failures. Secrets are never printed: the account number is masked, and a key found in a file is reported by file name only.
ExampleWhat a run looks like (an example, not a recording)python3 scripts/preflight.py --gate G1 --databricks-profile dev --aws-profile dev
[PASS] T1 Python 3.11 or newer: 3.12.4
[PASS] A1 signed in to AWS: arn:aws:iam::<account>:user/you
[FAIL] A2 S3 is allowed: AccessDenied: explicit deny in a service control policy
fix A2: ask the account owner to lift the policy that denies S3 (step 2)
[skip] A9 Terraform state bucket: needs A2 firstThe steps
| Step | What to do | Who | Note | Gate after it |
|---|---|---|---|---|
| 0 | Check out the code and the catalog; install Python, uv, Terraform 1.10+, the AWS CLI v2, the Databricks CLI, rsync | manual | Installing tools is a person's job. | G0 |
| 1 | Run the offline checks: tests, bundle check, Terraform validate | automated | make -C realms/aws-databricks check. Needs no account. | G0 |
| 2 | Sign in to AWS: aws configure sso, then aws sso login. If a policy denies a service, ask the account owner | manual | The preflight lists exactly which services answer and which are denied. | G1 |
| 3 | Create the Databricks account on AWS. Do not create a workspace in the quickstart. Note the account id | manual | Terraform creates the workspaces. | G1 |
| 4 | In the account console: group platform-admins, service principal dp-ci (account admin, in the group), a federation policy for GitHub Actions | manual | Not created by Terraform. Terraform needs an admin identity to exist first. | G1 |
| 5 | Make your local values file: copy infra/envs/dev.tfvars to dev.local.tfvars and fill in the prefix and ids | manual | The .local.tfvars file is git-ignored. Real values never go in a tracked file. | G0 |
| 6 | Sign in to Databricks: databricks auth login --host https://accounts.cloud.databricks.com --account-id ID, and a profile for the workspace later | manual | Opens a browser. | G1 |
| 7 | make bootstrap (state bucket), then make account (GitHub OIDC roles, the regional metastore, tags). Copy metastore_id into your local file | automated | Terraform and the AWS CLI do it. A person starts it once and copies two outputs. | G2 |
| 8 | Lakebase: check it is offered in the region. If not, set lakebase_enabled = false. Otherwise make the project, then run meta_setup.py | manual, then automated | The probe is a decision. The database, schemas, functions and manifest load are one idempotent script. | G4 |
| 9 | make deploy ENV=dev: infrastructure, then the asset bundle | automated | Buckets, keys, secrets, roles, workspace, catalogs, volume, jobs. | G3 |
| 10 | Put the secrets' values: aws secretsmanager put-secret-value .... Give dp-ci the admin role in the new workspace | manual | Terraform makes the secret, never its value. | G3 |
| 11 | GitHub: environments dev and prod (reviewers on prod), the repository and environment variables, then DEPLOY_ENABLED = true last | manual | Settings in the GitHub web page. Not code. | G5 |
| 12 | Run the job once: databricks bundle run engine_days (3 days). Look at the operations page it leaves in the volume | manual, then automated | A person starts it. The run, its checks and the report are automatic. | G6 |
| 13 | From here on: a pull request runs the checks and a real plan. A merge deploys dev and runs the integration test. Prod waits for a reviewer, then deploys the same commit | automated | The one manual act is the approval click on prod. | G6 |
| 14 | A day after the first deploy: switch on activate_cost_tags and run make account again | manual, then automated | So the cost tags appear in billing. | G6 |
What is code and what is by hand
| Thing | Where it comes from | Code or by hand |
|---|---|---|
| S3 buckets per layer, KMS key, IAM roles | Terraform: modules/storage, network, github_ci | code |
| Secret containers (Secrets Manager) | Terraform: modules/secrets | code |
| Secret values | aws secretsmanager put-secret-value | by hand, never in git |
| Kinesis, SNS, log group, budget | Terraform: modules/stream, alerts, budget | code |
| Workspace, metastore assignment, storage credential, external locations | Terraform: modules/workspace, unity_catalog | code |
| Catalogs by layer, schemas, landing volume | Terraform: modules/unity_catalog | code |
| Lakebase | Terraform modules/lakebase creates an instance. Lakebase has moved from instances to projects: verify the module against your workspace | code, to verify |
| Metadata store schemas and the manifest | meta_setup.py | automated, run by a person |
| Jobs and pipelines | Asset bundle: realms/databricks/engine, benchmarking/databricks | code |
Group, service principal dp-ci, federation policy | Account console | by hand |
Admin role for dp-ci in each workspace | Workspace settings | by hand |
| GitHub environments, variables, reviewers | Repository settings | by hand |
| Your own account values | infra/envs/NAME.local.tfvars | by hand, git-ignored |
Keys never go in git
Three rules, all checked by the gate G0. Real account values live in NAME.local.tfvars, which is git-ignored, and Make passes it after the tracked file. Secret values live only in the secret store. Tokens (a Databricks login, a Power BI token) come from the environment or a sign-in, and are held in the running process only. The gate checks that the ignore patterns are in place, scans every tracked text file for key-shaped text, and runs gitleaks over the history if it is installed.
Setting up Lakebase, the metadata database
The metadata store is a PostgreSQL database on Lakebase, one per environment. Setting it up is four steps, the last three in one idempotent script.
- Check. Lakebase must be offered in your region and tier. The gate G1 warns if it is not. If not, set
lakebase_enabled = falseand the same store binds to plain PostgreSQL. - Create. A Lakebase project or instance named for the environment. Terraform has a module for it; verify it against your workspace, because Lakebase changed from instances to projects.
- Wake and connect. A disabled endpoint is enabled, and a short-lived token is minted from your login. It lives in the process only.
- Install and load.
realms/aws-databricks/meta_setup.pycreates the database, installs the schemas and functions, loads the manifest, and reads it back as a check.
ExampleLoad the tyre manifest and record the table format and silver engine on every datasetpython3 realms/aws-databricks/meta_setup.py --instance dp-meta-dev \
--manifest ~/data-platform-catalog/slices/02-tyre/manifest \
--table-format delta-uc-uniform --silver-engine jobThe table format and silver engine are stored beside each dataset and are part of its fingerprint, so a run record shows which format it ran on. Be aware that today the run itself takes the table format from the job's parameter, not from the store, so the stored value documents the run and does not change it.
Fixing a failed gate
| What you see | What to do |
|---|---|
| G0 fails: a tool is old or missing | Install or upgrade the tool named. Terraform must be 1.10 or newer; the Databricks CLI must have bundles. |
| G0 fails: key-like text in a tracked file | Remove it, rotate the key, and keep the value in the secret store. The check names the file, never the value. |
| G1 fails: a service answers AccessDenied | An organisation policy or a missing permission denies it. Ask the account owner. For Kinesis alone, set streams = {}. |
| G1 fails: Databricks login | Run databricks auth login again. The token may have expired. |
| G2 fails: the state bucket is not reachable | Run make bootstrap. The bucket name is in account.backend.hcl. |
| G3 fails: a catalog is missing | make deploy did not finish. Read its Terraform error, fix, run it again. It is idempotent. |
| G3 fails: the secret does not exist | Terraform did not create it, or the prefix in your local file differs from the one used at deploy. |
| G4 fails: no Lakebase | Create the project, wake a disabled endpoint, then run meta_setup.py. Or set lakebase_enabled = false and bind plain PostgreSQL. |
| G5 fails: the bundle does not validate | Read the message it prints. Usually a wrong profile or a missing variable. |
| G6 fails: no report in the volume | The run failed. Open the job run, then the operations page of the last run. |
| The run says a table or schema already exists | Safe: every step is idempotent. Run it again. |
Day two: changing things
| Change | How |
|---|---|
| A new dataset | Add its manifest and contract in the catalog, load with meta_setup.py or the loader, deploy the bundle. No pipeline code. |
| A new environment | A new NAME.local.tfvars and a make deploy ENV=NAME. The gates take --env NAME. |
| A different table format | Change the job's table_format parameter and the stored setting. See Orchestration, end to end. |
| A rollback | Re-run the deploy at the previous commit. Terraform and the bundle are both declarative. |
- Nothing has been deployed on Databricks on AWS yet. The infrastructure is written and checked offline (validate and a plan on mocked providers). Only the Free Edition Databricks half was ever deployed, and its AWS half was blocked by the account's policy.
- The service principal, group and federation policy are made by hand. They could be Terraform at the account level once a first admin exists. That is not written.
- The Lakebase module creates the older instance shape. Lakebase has moved from instances to projects, so the module needs checking before the first real run.
- There is no gate that proves the manifest is loaded: that needs a database login, and the gate script only lists.
meta_setup.pyreads it back and says so. - Gate G6 checks that a report exists, not that its numbers equal the world's truth. That judgement is in the report itself.
- The steps were written from the realm's README, Makefile and workflow files. They have not been run end to end on a fresh account.