Manage configuration from CI
Keep applications, roles and webhooks in a repository, and apply them from a pipeline with the CLI and the Admin API.
This page is a draft. The code exists, and not all of it has been run for this page yet. The page says what was checked.
What it shows
- Three JSON files in your repository describe a role, an application and a webhook.
- A script compares each entry with your organization. It creates what is missing and updates what differs, so a second run changes nothing.
- LumoAuth returns the secret of a new application or webhook once. The script writes it to a file and never to the log.
- In a pull request, a GitHub Actions workflow applies the files to a new sandbox organization. It checks that a second run has nothing left to do, and then deletes the sandbox.
- A merge to
mainapplies the files to your organization.
The script exists twice: with the lumo CLI and with curl. Both read the same files and print the same lines.
Before you start
- An API key for the pipeline, with the scopes
admin:roles:write,admin:clients:write,admin:webhooks:writeand the matching:readscopes. For the sandbox step it also needsadmin:settings:write. Create it in the portal under Applications & developer tools, API keys. - The key acts with the permissions of the person who created it. That person must hold the permissions that the roles of the files grant.
- Change the address in
config/webhooks.jsonto your own receiver.https://example.com/lumoauth-webhookonly holds the place, and LumoAuth accepts only a public HTTPS address. - For the pull-request step, check that your plan includes sandbox organizations in the plans matrix.
- On your machine: the lumo CLI and
jqfor the CLI version,curlandjqfor the curl version.
To use the workflow, copy the files into your repository:
- Copy
github/lumoauth.ymlto.github/workflows/lumoauth.yml,cli/apply.shtolumoauth/apply.sh, and the folderconfig/tolumoauth/config/. - In GitHub, open Settings, Secrets and variables, Actions. Add the secret
LUMOAUTH_API_KEY, and the variablesLUMOAUTH_URLandLUMOAUTH_ORG_ID. - The job for
mainuses the environmentlumoauth. Give that environment a required reviewer if a person must approve each change to your organization.
| Variable | Value |
|---|---|
LUMOAUTH_URL | The address of LumoAuth: https://app.lumoauth.dev, or https://eu.app.lumoauth.dev for the EU region. |
LUMOAUTH_ORG_ID | Your organization, for example acme-corp. |
LUMOAUTH_API_KEY | An API key with the scopes admin:roles:write, admin:clients:write and admin:webhooks:write, and the matching :read scopes. The workflow also needs admin:settings:write for the sandbox organization. |
LUMO_ORG | Optional, CLI version only. The slug of a sandbox organization that lumo dev start created. The CLI then uses the API key that it saved for the sandbox. |
DRY_RUN | Optional. 1 reports what would change and changes nothing. The script then exits with status 2 when something would change. |
CONFIG_DIR | Optional. The folder with the three files. Default: config/ next to the script's folder. |
SECRETS_DIR | Optional. The folder that receives the secrets of new applications and webhooks. Default: lumoauth-secrets in the current folder. |
Code
Run each command from the recipes folder of the examples repository. Set the folder up once for your language. The output shows a first run and a second run.
- lumo CLI
- curl
- GitHub Actions
operations/configuration-from-ci/cli/apply.sh
#!/bin/sh
# Apply the files in config/ to an organization with the lumo CLI. The script
# changes only what differs from the files, so a second run changes nothing.
#
# sh operations/configuration-from-ci/cli/apply.sh
#
# DRY_RUN=1 only reports what would change, and then exits with status 2 when
# something would change. A pipeline uses it to check that nothing is left.
# The script needs the lumo CLI and jq.
set -eu
# The CLI has its own names for the three values of the recipes. For a
# sandbox organization, set LUMO_ORG to its slug: the CLI then uses the API
# key that `lumo dev start` saved for it.
export LUMO_BASE_URL="${LUMO_BASE_URL:-$LUMOAUTH_URL}"
export LUMO_ORG="${LUMO_ORG:-$LUMOAUTH_ORG_ID}"
export LUMO_API_KEY="${LUMO_API_KEY:-$LUMOAUTH_API_KEY}"
CONFIG="${CONFIG_DIR:-$(dirname "$0")/../config}"
SECRETS="${SECRETS_DIR:-lumoauth-secrets}"
DRY_RUN="${DRY_RUN:-0}"
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
CREATED=0 UPDATED=0 UNCHANGED=0
# One line for each resource, and the totals at the end.
report() { # <resource> <created|updated|unchanged>
case "$2" in
created) CREATED=$((CREATED + 1)) ;;
updated) UPDATED=$((UPDATED + 1)) ;;
*) UNCHANGED=$((UNCHANGED + 1)) ;;
esac
if [ "$DRY_RUN" = 1 ] && [ "$2" != unchanged ]; then echo "$1: would be $2"; else echo "$1: $2"; fi
}
# Every item of a list command, page by page, as one JSON array.
list_all() { # <command>
rm -f "$TMP"/page-*
PAGE=1
while :; do
lumo "$1" list --page "$PAGE" -o json > "$TMP/page-$PAGE"
[ "$(jq '(.pagination // .meta).hasNextPage' "$TMP/page-$PAGE")" = true ] || break
PAGE=$((PAGE + 1))
done
jq -s '[.[].data[]]' "$TMP"/page-*
}
# The CLI prints an error as JSON on standard output when -o json is set.
fail() { # <answer>
echo "$1" >&2
exit 1
}
# A one-time secret from a create answer goes to a file, never to the log.
save_secret() { # <answer> <file name>
SECRET=$(echo "$1" | jq -r '.data.secret // empty')
[ -n "$SECRET" ] || return 0
mkdir -p "$SECRETS"
(umask 077 && printf '%s\n' "$SECRET" > "$SECRETS/$2")
echo " the secret is in $SECRETS/$2: move it to your secrets manager"
}
# Each loop reads its file on descriptor 3, so that no command in it can
# read the rest of the file from standard input.
# 1. Roles, found by their slug. LumoAuth makes the slug from the name when
# it creates the role.
ROLES=$(list_all roles)
jq -c '.[]' "$CONFIG/roles.json" > "$TMP/roles"
while IFS= read -r WANT <&3; do
SLUG=$(printf '%s\n' "$WANT" | jq -r .slug)
NAME=$(printf '%s\n' "$WANT" | jq -r .name)
DESCRIPTION=$(printf '%s\n' "$WANT" | jq -r .description)
PERMISSIONS=$(printf '%s\n' "$WANT" | jq -r '.permissions | join(",")')
if [ -z "$(printf '%s\n' "$ROLES" | jq -r --arg s "$SLUG" '.[] | select(.slug == $s) | .id')" ]; then
if [ "$DRY_RUN" != 1 ]; then
ANSWER=$(lumo roles create --name "$NAME" --description "$DESCRIPTION" --permissions "$PERMISSIONS" -o json) || fail "$ANSWER"
MADE=$(printf '%s\n' "$ANSWER" | jq -r .data.slug)
if [ "$MADE" != "$SLUG" ]; then
echo "role \"$NAME\" got the slug $MADE: write that slug in roles.json" >&2
exit 1
fi
fi
report "role $SLUG" created
continue
fi
HAVE=$(lumo roles get "$SLUG" -o json | jq -c '.data | {name, description, permissions: ([.permissions[] | if type == "object" then .slug else . end] | sort)}')
if [ "$HAVE" = "$(printf '%s\n' "$WANT" | jq -c '{name, description, permissions: (.permissions | sort)}')" ]; then
report "role $SLUG" unchanged
else
if [ "$DRY_RUN" != 1 ]; then
ANSWER=$(lumo roles update "$SLUG" --name "$NAME" --description "$DESCRIPTION" --permissions "$PERMISSIONS" -o json) || fail "$ANSWER"
fi
report "role $SLUG" updated
fi
done 3< "$TMP/roles"
# 2. Applications for a server, found by their name. LumoAuth gives each one
# a client ID and a client secret.
APPS=$(list_all apps)
jq -c '.[]' "$CONFIG/applications.json" > "$TMP/apps"
while IFS= read -r WANT <&3; do
NAME=$(printf '%s\n' "$WANT" | jq -r .name)
URIS=$(printf '%s\n' "$WANT" | jq -r '.redirectUris | join(",")')
CLIENT_ID=$(printf '%s\n' "$APPS" | jq -r --arg n "$NAME" '[.[] | select(.name == $n)][0].clientId // empty')
if [ -z "$CLIENT_ID" ]; then
if [ "$DRY_RUN" != 1 ]; then
ANSWER=$(lumo apps create --name "$NAME" --redirect-uris "$URIS" -o json) || fail "$ANSWER"
fi
report "application \"$NAME\"" created
# The application is confidential, so LumoAuth returns its client secret once.
[ "$DRY_RUN" = 1 ] || save_secret "$ANSWER" "$(printf '%s\n' "$ANSWER" | jq -r .data.clientId).secret"
continue
fi
HAVE=$(lumo apps get "$CLIENT_ID" -o json | jq -c '.data.redirectUris | sort')
if [ "$HAVE" = "$(printf '%s\n' "$WANT" | jq -c '.redirectUris | sort')" ]; then
report "application \"$NAME\"" unchanged
else
if [ "$DRY_RUN" != 1 ]; then
ANSWER=$(lumo apps update "$CLIENT_ID" --redirect-uris "$URIS" -o json) || fail "$ANSWER"
fi
report "application \"$NAME\"" updated
fi
done 3< "$TMP/apps"
# 3. Webhooks, found by their address.
HOOKS=$(list_all webhooks)
jq -c '.[]' "$CONFIG/webhooks.json" > "$TMP/hooks"
while IFS= read -r WANT <&3; do
URL=$(printf '%s\n' "$WANT" | jq -r .url)
EVENTS=$(printf '%s\n' "$WANT" | jq -r '.events | join(",")')
HAVE=$(printf '%s\n' "$HOOKS" | jq -c --arg u "$URL" '[.[] | select(.url == $u)][0] // empty')
if [ -z "$HAVE" ]; then
if [ "$DRY_RUN" != 1 ]; then
ANSWER=$(lumo webhooks create --url "$URL" --events "$EVENTS" -o json) || fail "$ANSWER"
fi
report "webhook $URL" created
[ "$DRY_RUN" = 1 ] || save_secret "$ANSWER" "webhook-$(printf '%s\n' "$ANSWER" | jq -r .data.id).secret"
continue
fi
if [ "$(printf '%s\n' "$HAVE" | jq -c '.events | sort')" = "$(printf '%s\n' "$WANT" | jq -c '.events | sort')" ]; then
report "webhook $URL" unchanged
else
if [ "$DRY_RUN" != 1 ]; then
ANSWER=$(lumo webhooks update "$(printf '%s\n' "$HAVE" | jq -r .id)" --events "$EVENTS" -o json) || fail "$ANSWER"
fi
report "webhook $URL" updated
fi
done 3< "$TMP/hooks"
if [ "$DRY_RUN" != 1 ]; then
echo "$CREATED created, $UPDATED updated, $UNCHANGED unchanged"
else
echo "$CREATED to create, $UPDATED to update, $UNCHANGED unchanged"
[ $((CREATED + UPDATED)) = 0 ] || exit 2
fi
operations/configuration-from-ci/config/roles.json
[
{
"slug": "support-desk",
"name": "Support desk",
"description": "Looks up people and their groups for the help desk.",
"permissions": ["groups.view", "users.view"]
}
]
operations/configuration-from-ci/config/applications.json
[
{
"name": "Acme support console",
"redirectUris": ["https://support.acme.example/auth/callback", "http://localhost:3000/auth/callback"]
}
]
operations/configuration-from-ci/config/webhooks.json
[
{
"url": "https://example.com/lumoauth-webhook",
"events": ["user.created", "user.deleted"]
}
]
sh operations/configuration-from-ci/cli/apply.sh
Run against a LumoAuth organization.
operations/configuration-from-ci/http/apply.sh
#!/bin/sh
# Apply the files in config/ to an organization with curl and the Admin API.
# The script changes only what differs from the files, so a second run
# changes nothing.
#
# sh operations/configuration-from-ci/http/apply.sh
#
# DRY_RUN=1 only reports what would change, and then exits with status 2 when
# something would change. A pipeline uses it to check that nothing is left.
# The script needs curl and jq.
set -eu
API="$LUMOAUTH_URL/orgs/$LUMOAUTH_ORG_ID/api/v1/admin"
CONFIG="${CONFIG_DIR:-$(dirname "$0")/../config}"
SECRETS="${SECRETS_DIR:-lumoauth-secrets}"
DRY_RUN="${DRY_RUN:-0}"
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
CREATED=0 UPDATED=0 UNCHANGED=0
# One request to the Admin API. Stops the script on an error status.
call() { # <method> <path> [json body]
curl --silent --show-error --fail-with-body --request "$1" "$API$2" \
--header "X-API-Key: $LUMOAUTH_API_KEY" \
--header "Content-Type: application/json" \
${3:+--data "$3"}
}
# Every item of a list endpoint, page by page, as one JSON array.
list_all() { # <path>
PAGE=1 ITEMS='[]'
while :; do
ANSWER=$(call GET "$1?page=$PAGE&limit=100")
ITEMS=$(printf '%s\n%s' "$ITEMS" "$ANSWER" | jq -s '.[0] + .[1].data')
[ "$(printf '%s\n' "$ANSWER" | jq '(.pagination // .meta).hasNextPage')" = true ] || break
PAGE=$((PAGE + 1))
done
echo "$ITEMS"
}
# One line for each resource, and the totals at the end.
report() { # <resource> <created|updated|unchanged>
case "$2" in
created) CREATED=$((CREATED + 1)) ;;
updated) UPDATED=$((UPDATED + 1)) ;;
*) UNCHANGED=$((UNCHANGED + 1)) ;;
esac
if [ "$DRY_RUN" = 1 ] && [ "$2" != unchanged ]; then echo "$1: would be $2"; else echo "$1: $2"; fi
}
# A one-time secret from a create answer goes to a file, never to the log.
save_secret() { # <answer> <file name>
SECRET=$(echo "$1" | jq -r '.data.secret // empty')
[ -n "$SECRET" ] || return 0
mkdir -p "$SECRETS"
(umask 077 && printf '%s\n' "$SECRET" > "$SECRETS/$2")
echo " the secret is in $SECRETS/$2: move it to your secrets manager"
}
# Each loop reads its file on descriptor 3, so that no command in it can
# read the rest of the file from standard input.
# 1. Roles, found by their slug. The API takes the slug on create.
ROLES=$(list_all /roles)
jq -c '.[]' "$CONFIG/roles.json" > "$TMP/roles"
while IFS= read -r WANT <&3; do
SLUG=$(printf '%s\n' "$WANT" | jq -r .slug)
if [ -z "$(printf '%s\n' "$ROLES" | jq -r --arg s "$SLUG" '.[] | select(.slug == $s) | .id')" ]; then
[ "$DRY_RUN" = 1 ] || call POST /roles "$WANT" > /dev/null
report "role $SLUG" created
continue
fi
HAVE=$(call GET "/roles/$SLUG" | jq -c '.data | {name, description, permissions: ([.permissions[].slug] | sort)}')
if [ "$HAVE" = "$(printf '%s\n' "$WANT" | jq -c '{name, description, permissions: (.permissions | sort)}')" ]; then
report "role $SLUG" unchanged
else
if [ "$DRY_RUN" != 1 ]; then
# Name and description, then the full list of permissions.
call PATCH "/roles/$SLUG" "$(printf '%s\n' "$WANT" | jq -c '{name, description}')" > /dev/null
call PUT "/roles/$SLUG/permissions" "$(printf '%s\n' "$WANT" | jq -c '{permissions}')" > /dev/null
fi
report "role $SLUG" updated
fi
done 3< "$TMP/roles"
# 2. Applications for a server, found by their name. LumoAuth gives each one
# a client ID and a client secret.
APPS=$(list_all /clients)
jq -c '.[]' "$CONFIG/applications.json" > "$TMP/apps"
while IFS= read -r WANT <&3; do
NAME=$(printf '%s\n' "$WANT" | jq -r .name)
CLIENT_ID=$(printf '%s\n' "$APPS" | jq -r --arg n "$NAME" '[.[] | select(.name == $n)][0].clientId // empty')
if [ -z "$CLIENT_ID" ]; then
if [ "$DRY_RUN" != 1 ]; then
ANSWER=$(call POST /clients "$WANT")
fi
report "application \"$NAME\"" created
# The application is confidential, so LumoAuth returns its client secret once.
[ "$DRY_RUN" = 1 ] || save_secret "$ANSWER" "$(printf '%s\n' "$ANSWER" | jq -r .data.clientId).secret"
continue
fi
HAVE=$(call GET "/clients/$CLIENT_ID" | jq -c '.data.redirectUris | sort')
if [ "$HAVE" = "$(printf '%s\n' "$WANT" | jq -c '.redirectUris | sort')" ]; then
report "application \"$NAME\"" unchanged
else
[ "$DRY_RUN" = 1 ] || call PATCH "/clients/$CLIENT_ID" "$(printf '%s\n' "$WANT" | jq -c '{redirectUris}')" > /dev/null
report "application \"$NAME\"" updated
fi
done 3< "$TMP/apps"
# 3. Webhooks, found by their address.
HOOKS=$(list_all /webhooks)
jq -c '.[]' "$CONFIG/webhooks.json" > "$TMP/hooks"
while IFS= read -r WANT <&3; do
URL=$(printf '%s\n' "$WANT" | jq -r .url)
HAVE=$(printf '%s\n' "$HOOKS" | jq -c --arg u "$URL" '[.[] | select(.url == $u)][0] // empty')
if [ -z "$HAVE" ]; then
if [ "$DRY_RUN" != 1 ]; then
ANSWER=$(call POST /webhooks "$WANT")
fi
report "webhook $URL" created
[ "$DRY_RUN" = 1 ] || save_secret "$ANSWER" "webhook-$(printf '%s\n' "$ANSWER" | jq -r .data.id).secret"
continue
fi
if [ "$(printf '%s\n' "$HAVE" | jq -c '.events | sort')" = "$(printf '%s\n' "$WANT" | jq -c '.events | sort')" ]; then
report "webhook $URL" unchanged
else
# The same address, so this is no move, and the signing secret stays.
[ "$DRY_RUN" = 1 ] || call PUT "/webhooks/$(printf '%s\n' "$HAVE" | jq -r .id)" "$WANT" > /dev/null
report "webhook $URL" updated
fi
done 3< "$TMP/hooks"
if [ "$DRY_RUN" != 1 ]; then
echo "$CREATED created, $UPDATED updated, $UNCHANGED unchanged"
else
echo "$CREATED to create, $UPDATED to update, $UNCHANGED unchanged"
[ $((CREATED + UPDATED)) = 0 ] || exit 2
fi
operations/configuration-from-ci/config/roles.json
[
{
"slug": "support-desk",
"name": "Support desk",
"description": "Looks up people and their groups for the help desk.",
"permissions": ["groups.view", "users.view"]
}
]
operations/configuration-from-ci/config/applications.json
[
{
"name": "Acme support console",
"redirectUris": ["https://support.acme.example/auth/callback", "http://localhost:3000/auth/callback"]
}
]
operations/configuration-from-ci/config/webhooks.json
[
{
"url": "https://example.com/lumoauth-webhook",
"events": ["user.created", "user.deleted"]
}
]
sh operations/configuration-from-ci/http/apply.sh
Run against a LumoAuth organization.
operations/configuration-from-ci/github/lumoauth.yml
# Apply the LumoAuth configuration of this repository from GitHub Actions.
# Copy this file to .github/workflows/lumoauth.yml, cli/apply.sh to
# lumoauth/apply.sh and config/ to lumoauth/config/.
#
# A pull request applies the files to a new sandbox organization, checks that
# a second run has nothing left to do, and deletes the sandbox. A merge to
# main applies them to your organization.
#
# Repository settings: the secret LUMOAUTH_API_KEY, and the variables
# LUMOAUTH_URL (https://app.lumoauth.dev or https://eu.app.lumoauth.dev)
# and LUMOAUTH_ORG_ID.
name: LumoAuth configuration
on:
pull_request:
paths: ["lumoauth/**"]
push:
branches: [main]
paths: ["lumoauth/**"]
# One run at a time, so that two merges never apply at the same moment.
concurrency: lumoauth-configuration
env:
LUMOAUTH_URL: ${{ vars.LUMOAUTH_URL }}
LUMOAUTH_ORG_ID: ${{ vars.LUMOAUTH_ORG_ID }}
LUMOAUTH_API_KEY: ${{ secrets.LUMOAUTH_API_KEY }}
CONFIG_DIR: lumoauth/config
SECRETS_DIR: ${{ github.workspace }}/../lumoauth-secrets
jobs:
sandbox:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install the lumo CLI
run: |
curl -fsSL https://raw.githubusercontent.com/LumoAuth/cli/main/install.sh | sh
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Start a sandbox organization
env:
LUMO_BASE_URL: ${{ vars.LUMOAUTH_URL }}
LUMO_ORG: ${{ vars.LUMOAUTH_ORG_ID }}
LUMO_API_KEY: ${{ secrets.LUMOAUTH_API_KEY }}
run: |
# The CLI saves the API key of the sandbox, and the JSON answer
# holds it too: keep only the slug.
SLUG=$(lumo dev start --name "pr-${{ github.event.number }}" --ttl-hours 2 -o json | jq -r .data.slug)
echo "SANDBOX=$SLUG" >> "$GITHUB_ENV"
- name: Apply the configuration to the sandbox
run: LUMO_ORG="$SANDBOX" sh lumoauth/apply.sh
- name: Check that a second run changes nothing
run: LUMO_ORG="$SANDBOX" DRY_RUN=1 sh lumoauth/apply.sh
# Run the tests of your application against the sandbox here.
- name: Delete the sandbox
if: always() && env.SANDBOX != ''
env:
LUMO_BASE_URL: ${{ vars.LUMOAUTH_URL }}
LUMO_ORG: ${{ vars.LUMOAUTH_ORG_ID }}
LUMO_API_KEY: ${{ secrets.LUMOAUTH_API_KEY }}
run: lumo dev stop "$SANDBOX"
organization:
if: github.event_name == 'push'
runs-on: ubuntu-latest
# A protected environment can ask a person to approve the run first.
environment: lumoauth
steps:
- uses: actions/checkout@v4
- name: Install the lumo CLI
run: |
curl -fsSL https://raw.githubusercontent.com/LumoAuth/cli/main/install.sh | sh
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Show what will change
run: DRY_RUN=1 sh lumoauth/apply.sh || [ $? = 2 ]
- name: Apply the configuration
run: sh lumoauth/apply.sh
# A new application or webhook writes its one-time secret to
# SECRETS_DIR. Move it to your secrets manager in this step, with the
# command line tool of that manager. The files end with the job.
- name: Store new secrets
run: ls "$SECRETS_DIR" 2>/dev/null || echo "no new secrets"
Compiles. Not run against an organization. The workflow passed actionlint, and its steps ran on a local machine against an organization and a sandbox organization. It did not run on GitHub Actions.
Check the result
Output
role support-desk: created
application "Acme support console": created
the secret is in lumoauth-secrets/client_7534c380b75e4e8c8d22a84c98be0c0e.secret: move it to your secrets manager
webhook https://example.com/lumoauth-webhook: created
the secret is in lumoauth-secrets/webhook-53.secret: move it to your secrets manager
3 created, 0 updated, 0 unchanged
role support-desk: unchanged
application "Acme support console": unchanged
webhook https://example.com/lumoauth-webhook: unchanged
0 created, 0 updated, 3 unchanged
- The first run creates the three entries. The second run reports
0 created, 0 updated, 3 unchanged. - Run it with
DRY_RUN=1to see what would change. The pull-request job uses it as a test: the step fails when a second run would still change something. - The portal shows the role under Roles & permissions, the application under Applications, and the webhook under Integrations, Webhooks.
- Change a permission in
config/roles.jsonand run the script again. It reportsrole support-desk: updated.
Limits
- The script never deletes. An entry that you remove from a file stays in the organization until you delete it in the portal, or with
lumo roles delete,lumo apps deleteorlumo webhooks delete. - A role is found by its slug, which LumoAuth makes from the name when the CLI creates the role. The CLI version stops when the two do not match. The curl version sends the slug with the role.
- An application is found by its name, so a new name creates a second application.
- The CLI creates confidential applications, which have a client secret. For a public application (a single-page or native app), send
"isConfidential": falsein the request body, as the curl version can. - A webhook is found by its address. A new address makes a new webhook with a new signing secret.
- LumoAuth has no Terraform provider and no Kubernetes operator. This recipe is the supported pattern, as Configuration as code describes.