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

Return to the regular view of this page.

MLOps GitLab Terraform

    This Terraform root targets the course GitLab API at mlops-rc.gitlab.yandexcloud.net. It starts with the provider and Vault-backed HTTP state configured.

    The account identified by the Vault token gets two public SSH keys. The Vault simeonwarrenbot key uses GitLab’s default authentication and signing scope. Terraform reads metadata.sshpubkey directly from the Vault entity using the project AppRole’s exact-path read grant. The Forgejo instance key uses signing only. Forgejo setup publishes it to the public-only KV record beside its private key record. The GitLab AppRole can read the public record. Terraform enrolls the key through the GitLab API at apply time. Terraform tracks enrollment, and GitLab owns subsequent removal or drift reconciliation for that signing-only key.

    Once a Vault administrator has applied the dedicated AppRole and read grant, run this from the repository root using a Vault identity authorized to bootstrap the role. Paste a GitLab token with the api scope and permissions for the resources Terraform will manage.

    (
      set +x
      unset mlops_gitlab_token
      IFS= read -r -s -p 'MLOps GitLab API token: ' mlops_gitlab_token || exit 1
      printf '\n' >&2
      [ -n "$mlops_gitlab_token" ] || exit 1
      printf '%s' "$mlops_gitlab_token" |
        bazel run //projects/mlops_2026/tf/gitlab:vault.kv_put -- \
          alwaldend.com/vault1/approles/src_projects_mlops_2026_gitlab/gitlab gitlab_token=-
    )
    

    The credential is stored as a single-field KV entry. Repeating the command replaces that entry with the new token. Terraform receives it as GITLAB_TOKEN.

    bazel run //projects/mlops_2026/tf/gitlab:tf.plan
    

    The module_3 project starts empty in the token account’s namespace. Push master as the first branch. Internal visibility lets authenticated non-external users clone the project. Terraform grants direct Reporter membership to active Maintainers and Owners of mlops-yandex-practicum. Each plan refreshes the group roles. Review any resulting membership additions or removals before apply.

    The master branch protection permits Maintainers and Owners to push and merge, with force pushes disabled. Adopt any protection GitLab creates on the first push through a Terraform import before applying the rule.

    GitLab looks for projects/mlops_2026/module_3/.gitlab-ci.yaml relative to the root of the repository. The course branch must include that file to run the custom pipeline.