AppRole is the Vault auth method for non-human clients—applications, batch jobs, and CI/CD pipelines. It issues a service token using two factors: a RoleID (identifier) and a SecretID (credential).
This article sticks to the stable configuration options documented officially and covers secure SecretID delivery, response wrapping, using Vault Agent, and choosing AppRole versus other auth methods in real-world operations.
AppRole lets Vault issue a service token for an application using a RoleID (a fixed identifier) and a SecretID (a short-lived credential with a configurable use count). Token characteristics (policies, TTL, max TTL, renewability, CIDR constraints) can be declared per role.
Because no human interaction is required, AppRole works reliably at process startup and during container initialization. Unlike Kubernetes Auth or JWT/OIDC—which depend on a specific environment—AppRole tends to be the default choice across any runtime (VMs, on-premises, edge).
The typical flow: define the role on the management side (SecOps/CI), distribute the RoleID to the application, and deliver the SecretID safely as a one-time payload using response wrapping. The application logs in with the RoleID and SecretID and uses the resulting Vault token to fetch secrets.
The key is to treat SecretIDs as ephemeral, least-privileged, and use-limited. The token itself should also be scoped tightly by policy and TTL so that any leak has a small blast radius.
Conceptual diagram: AppRole authentication and token issuance
A SecretID is effectively a password. The two things that matter most are securing the delivery path and keeping it short-lived with a use limit. Response wrapping lets you deliver a short-TTL, single-use wrap token instead of the SecretID itself.
In the role configuration, combine secret_id_num_uses (e.g., 1), secret_id_ttl (e.g., 10 minutes), and secret_id_bound_cidrs (source CIDR restrictions) to contain the impact of a leak. On the token side, tighten the scope further with token_ttl, token_max_ttl, and token_bound_cidrs.
The following is the stable baseline procedure. In production, tune the CIDR constraints and TTL values to your environment. The API uses paths under /v1/auth/approle.
When you add Vault Agent's auto_auth, the application only needs to read the RoleID and SecretID files; subsequent token renewals are automated.
Minimum example for CLI / API / Agent
# 0) 前提
export VAULT_ADDR=https://vault.example.com
export VAULT_TOKEN=<operator_root_or_admin_token>
# 1) AppRoleを有効化
vault auth enable approle
# 2) 最小権限のポリシー作成(例)
cat > app.hcl <<'HCL'
path "secret/data/app/*" {
capabilities = ["read"]
}
HCL
vault policy write app app.hcl
# 3) ロール作成(推奨パラメータ例)
vault write auth/approle/role/my-app \
token_policies="app" \
bind_secret_id=true \
secret_id_num_uses=1 \
secret_id_ttl=10m \
token_ttl=1h \
token_max_ttl=4h \
token_bound_cidrs="10.0.0.0/8" \
secret_id_bound_cidrs="10.0.0.0/8" \
local_secret_ids=true
# 4) RoleIDの取得(配布は安全経路で)
ROLE_ID=$(vault read -field=role_id auth/approle/role/my-app/role-id)
echo "$ROLE_ID" > role_id
# 5) SecretIDの発行(Wrapして配布)
WRAP_TOKEN=$(vault write -f -wrap-ttl=5m auth/approle/role/my-app/secret-id | awk '/wrapping_token/ {print $2}')
# 受け取り側:
SECRET_ID=$(VAULT_TOKEN=$WRAP_TOKEN vault unwrap -field=secret_id)
echo "$SECRET_ID" > secret_id
# 6) ログイン(サービストークン取得)
APP_TOKEN=$(vault write -field=token auth/approle/login role_id="$ROLE_ID" secret_id="$SECRET_ID")
echo "$APP_TOKEN" > app.token
# --- 同等のHTTP API例 ---
# ロール作成
curl -sS \
-H "X-Vault-Token: $VAULT_TOKEN" \
-H "Content-Type: application/json" \
-X POST \
-d '{
"token_policies":"app",
"bind_secret_id":true,
"secret_id_num_uses":1,
"secret_id_ttl":"10m",
"token_ttl":"1h",
"token_max_ttl":"4h",
"token_bound_cidrs":["10.0.0.0/8"],
"secret_id_bound_cidrs":["10.0.0.0/8"],
"local_secret_ids":true
}' \
$VAULT_ADDR/v1/auth/approle/role/my-app
# RoleID取得
curl -sS -H "X-Vault-Token: $VAULT_TOKEN" \
$VAULT_ADDR/v1/auth/approle/role/my-app/role-id | jq -r .data.role_id
# SecretID(Wrap)
curl -sS -H "X-Vault-Token: $VAULT_TOKEN" \
-H "X-Vault-Wrap-TTL: 5m" \
-X POST $VAULT_ADDR/v1/auth/approle/role/my-app/secret-id | jq -r .wrap_info.token
# ログイン
curl -sS -H "Content-Type: application/json" \
-X POST \
-d '{"role_id":"'$ROLE_ID'","secret_id":"'$SECRET_ID'"}' \
$VAULT_ADDR/v1/auth/approle/login | jq -r .auth.client_token
# --- Vault Agent(auto_auth)例 ---
cat > agent.hcl <<'HCL'
auto_auth {
method "approle" {
config = {
role_id_file_path = "./role_id"
secret_id_file_path = "./secret_id"
}
}
sink "file" {
config = {
path = "/tmp/app.token"
}
}
}
cache {
use_auto_auth_token = true
}
HCL
vault agent -config=agent.hcl
SecretID rotation should be automated. Build a pipeline in CI that periodically issues a new SecretID, hands it off via wrapping, and destroys the old one. If a leak is detected, you can destroy/revoke through the secret-id access path.
Issued tokens can be renewed within token_ttl and token_max_ttl. Make Vault Agent's automatic renewal the default, and add health checks and fallbacks for cases when renewal fails (max_ttl reached or insufficient permissions).
AppRole's strength is that it works anywhere. By contrast, Kubernetes Auth and JWT/OIDC become operationally lighter the deeper your environment integration goes. The exam frequently asks you to pick the right tool for the job.
AppRole is the default for CI/CD, on-premises VMs, and edge environments. In Kubernetes, consider Kubernetes Auth first; if you have external identity provider integration, JWT/OIDC is a strong option. TLS certificate auth fits environments with mature client certificate management.
| Method | Typical use / prerequisites | Delivery / rotation difficulty | Strengths / caveats |
|---|---|---|---|
| AppRole | Generic apps, batch, CI. Environment-agnostic | Hinges on safe SecretID delivery, short TTL, and use limits | Works anywhere. Combine wrapping with Vault Agent for secure automation |
| Kubernetes Auth | Kubernetes environments. Validates SA tokens | No distribution needed (uses the SA token) | Easy Kubernetes integration. Permissions managed via role binding |
| JWT/OIDC Auth | External IdP integration. OIDC/JWT issuance platform | No distribution needed (the JWT is presented) | Federation-friendly. Policies can be assigned from claims |
| TLS Cert Auth | Environments where mTLS is already in place | Requires certificate distribution and renewal | Strong via mutual TLS, but certificate operations are costly |
Associate
問題 1
In a Vault AppRole design where an application authenticates, which combination is recommended to safely deliver the SecretID while also minimizing the impact of a potential leak?
正解: B
AppRole best practice is to deliver the SecretID securely via response wrapping, restrict the use count (secret_id_num_uses=1) and lifetime (secret_id_ttl), and—when possible—add CIDR constraints (secret_id_bound_cidrs) to minimize blast radius. A, C, and D all fall short on either SecretID handling or authentication strength.
Should RoleID be treated as a secret?
RoleID is an identifier, not a secret in the same strict sense as SecretID. Still, minimizing its exposure is recommended. Authenticity is guaranteed by the SecretID (and other constraints), so the rule of thumb is to keep bind_secret_id=true.
Can you run without a SecretID (bind_secret_id=false)?
Technically possible, but not recommended. Logging in with RoleID alone is too weak. In production, keep bind_secret_id=true and combine it with secret_id_num_uses, secret_id_ttl, CIDR constraints, and response wrapping.
How do you revoke and rotate SecretIDs and tokens?
SecretIDs can be destroyed individually via auth/approle/role/<role>/secret-id/destroy. Tokens can be revoked using revoke or revoke-prefix by accessor or path. The standard pattern is to automate rotation in CI (reissue SecretID → wrap → deliver → destroy the old ID) and let Vault Agent handle token renewals.
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
Vault Core Concepts: Sealed/Unsealed, Auth, Secrets (2026)
Vault fundamentals — sealed/unsealed state, auth methods, se...
Vault Operations Professional (VOP-003): Complete Guide (2026)
Pass the Vault Operations Professional exam — enterprise pat...
Vault Path-Based Routing: API URL Structure (2026)
How Vault's path-based routing works — mount points, sub-pat...
Vault Tokens: Auth Token Mechanics (2026)
Token fundamentals — service vs. batch tokens, accessor, ren...
Vault Token Types: Service, Batch, Periodic (2026)
Service vs. batch tokens compared — performance, ACL behavio...