This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Vast.ai

Account, team, and rental infrastructure with Vault authentication

This project manages Vast.ai through three independent Terraform roots:

RootCredentialOwnsState suffix
AccountPersonal account keyTeam identities, account settings and SSH keystf
AlwaldendOperator-provided alwaldend keyFull-access team keys and team settingsalwaldend
Rental testGenerated alwaldend rental keyOne test GPU contractrental_test

config.json defines environment settings once. The account and alwaldend roots both read that section because teams do not inherit account variables. ENABLE_HTTPS, WEB_ENABLE_HTTPS and WEB_ENABLE_AUTH are all true. The account root currently declares only alwaldend. Two former imported teams remain tracked pending credential recovery for deletion; the managed test team and its test objects have been deleted. See the live evidence.

Image-generation rentals charge the alwaldend team. Read its current prepaid credit without printing the rest of the account response:

bazel run //infra/vastai/alwaldend -- --raw show user |
  python3 -c 'import json, sys; print("USD {:.2f}".format(json.load(sys.stdin)["credit"]))'

The credit field is the remaining prepaid amount in USD; the separate balance field is not that amount. The command reads live data through the existing Vault injection and does not rent capacity or change the account. Use the team target above for these rentals; //infra/vastai selects the personal account instead. Retained instances continue to consume credit until released.

The component uses the src_infra_vastai Vault AppRole declared in Vault Terraform. Secret references use the secrets mount and its existing component namespace. Credentials are injected into process environments; they are not command-line arguments or persistent CLI key files.

Vault path below alwaldend.com/vault1/approles/src_infra_vastai/Owner
vastaiOperator-provided personal account key
vastai/alwaldendOperator-provided root team key
vastai/alwaldend/rentalsTeam root’s generated rental key

The existing alwaldend root also declares a dedicated token into the src_infra_image_gen/vastai component namespace. The existing team Vault writer has an exact-path delivery permission for that entry. The infrastructure rental reads it with its own AppRole and uses the generated team key to provision the instance.

Each entry stores field api_key. The team root preserves its own seed key. New API keys inherit the issuer’s current account. The pinned CLI has no team selector for create api-key; its team help directs operators to select an existing team in the console and create its initial key there. Configure each provider with the appropriate credential rather than switching API-key context.

The following one-time bootstrap command writes only the root team key and keeps it out of shell history and process arguments:

(
  set +x
  unset vastai_team_key
  IFS= read -r -s -p 'Alwaldend team key: ' vastai_team_key || exit 1
  printf '\n'
  [ -n "$vastai_team_key" ] || exit 1
  printf '%s' "$vastai_team_key" |
    bazel run //infra/vastai:vault -- kv put -mount=secrets \
      alwaldend.com/vault1/approles/src_infra_vastai/vastai/alwaldend api_key=-
)

The user authorized this operator bootstrap; IaC contains only its reference. The pinned CLI can verify each context:

bazel run //infra/vastai -- show user
bazel run //infra/vastai/alwaldend -- show user

The HTTP backend stores each root’s lock and state under its configured tf_backend/STATE_SUFFIX entry. The image-generation token and its component Vault entry are owned by the existing team backend without reusing the destroyed personal key. Building or testing these targets does not authenticate or change live infrastructure.

1 - Alwaldend team configuration

Full-access team keys and shared team environment settings

This separate Terraform root uses the operator-provided alwaldend team key from Vault as its default provider credential. It configures the shared environment_variables map from ../config.json and creates the full-access keys listed in teams.alwaldend.api_keys. Each generated key is stored at secrets/alwaldend.com/vault1/approles/src_infra_vastai/vastai/alwaldend/KEY_NAME. Secret values are sensitive and are not outputs.

The dedicated image-generation key name comes from teams.alwaldend.image_gen_api_key_name. The existing alwaldend Vast credential generates that key. The existing src_infra_vastai Vault identity writes its value directly to alwaldend.com/vault1/approles/src_infra_image_gen/vastai, using the default Vault provider. Its delivery policy is limited to this exact entry. The infrastructure rental reads the stored key with its own AppRole. The writer can delete metadata for this exact entry so its managed key delivery is removed completely during teardown.

The former personal key and its delivery entry were destroyed on 2026-11-10. The fresh component key has been created and delivered to its own namespace. The component receipt records its reviewed creation without a rental. No state handoff or import is needed. The change record retains the previous handoff history and current teardown evidence.

The root seed key at the parent vastai/alwaldend path is operator-owned. This root neither replaces nor deletes it. The account root owns team creation; this root owns no teams, rentals or credit transfers. Its Vault-backed backend is tf_backend/alwaldend, independent of the account and rental states.

bazel run //infra/vastai/alwaldend -- show user
bazel run //infra/vastai/alwaldend:tf.plan
bazel run //infra/vastai/alwaldend:tf.apply

Verify that the seed selects alwaldend and review the interactive apply before approving it. Do not save plans or use automatic approval. The component AppRole owns team credentials/state and the exact-path token delivery permission. The owning Vault workflow manages that narrow permission. The acceptance record records the legacy grant; the component receipt above records the new deployment.

Rent and release compute through the separate rental test, which reads the generated rentals key. Running this root does not rent compute.

2 - Vast.ai account configuration

Account settings and protected team identities

This root uses the personal account credential to manage account environment settings and the team names in ../config.json. The configuration currently retains only alwaldend. Its identity is protected against deletion and its funded account must not be recreated or replaced.

The account root creates no project API keys or rental contracts. The separate alwaldend root uses its operator-provided team credential to manage team keys and settings. Both roots read the same environment_variables section: ENABLE_HTTPS, WEB_ENABLE_HTTPS and WEB_ENABLE_AUTH are true. Teams do not inherit the account settings, so the team root applies the same map.

bazel run //infra/vastai/tf:tf.plan
bazel run //infra/vastai/tf:tf.apply

Review the interactive apply plan. Reject changes to alwaldend ownership, account identity or credit. Never save plans or use automatic approval.

The prior live test root’s three objects, the test_vastai_provider team, its generated credentials, and its Vault entry were deleted through their original states. The two imported teams projects_vastai_terraform_prov and test_vastai_terraform_provider remain tracked pending deletion: the provider refuses destruction because their management credentials were not recovered. They are absent from desired configuration; they have not been detached from state or reported as deleted.

The existing alwaldend identity and three account variable addresses were reconciled within the same state. Completed migration blocks were removed. No resource was transferred between states.

//infra/vastai/test/catalog:catalog_test exercises both actual roots with mock providers, verifies shared settings and full-access key declarations, and rejects invalid key names. It also verifies public-key metadata rotation and refusal of missing or invalid SSH metadata. It uses no live credentials or infrastructure.

The account root manages vastai_ssh_key.host for each ssh_key_entities entry in the shared configuration. It reads the entity’s sshpubkey from Vault at identity/entity/name/<entity>. The component AppRole has an exact-path metadata read for the configured host user; the root contains no public-key literal or private material. The same Vault identity is injected alongside the account credential through the existing AL configuration.

This is account-wide registration, explicitly requested by the operator. Vast owns propagation to instances; verify access before running deployment. An already registered key must be imported into its matching resource before apply rather than duplicated. Updating this source does not apply policy, register a key or modify an existing instance. Review the owning interactive Vault and account applies separately when deployment is authorized.

3 - Vast.ai rental test

Rent the cheapest on-demand GPU in alwaldend and release it

This flat Terraform root owns one test contract, independently of account and team IaC. The provider reads VAST_API_KEY, injected from the generated team key at secrets/alwaldend.com/vault1/approles/src_infra_vastai/vastai/alwaldend/rentals. The alwaldend root owns that key. The backend retains the existing tf_backend/rental_test path.

bazel run //infra/vastai/rentals_test:tf.plan
bazel run //infra/vastai/rentals_test:tf.rent
bazel run //infra/vastai/rentals_test:tf.release
bazel run //infra/vastai/rentals_test:tf.state -- list
bazel run //infra/vastai/alwaldend -- show instances

Review both interactive applies. Start release immediately after rent returns, including after a failed creation apply, and approve destruction promptly. There is no boot wait or workload. Confirm empty Terraform state and absence of the contract in the CLI inventory. Release destroys the contract and local disk; stopping a contract alone retains storage charges.

The search takes one rentable, unoccupied on-demand GPU offer ordered by total hourly price. It includes the 3.5 GB disk allocation used by ubuntu:24.04 and rejects prices above USD 1 per hour. Network charges are separate. There are no model or verification filters and no creation retries. An existing contract retains its original offer; selected_offer describes the current marketplace. Destroy mode releases the recorded contract without searching for another offer.

Building or testing the package does not rent compute. The offline catalog test validates this root with the packaged provider. Provider acceptance tests cover the Terraform rental lifecycle against a local API fixture.