You are configuring a Vault Agent to use the AppRole auth method. The agent must retrieve a secret from a KV v2 secrets engine and render it into a configuration file. The secret path is 'secret/data/myapp/config'. Which template function should you use to access the secret's data?
For KV v2, secrets are nested under 'data.data'. The 'secret' function retrieves the secret, and the correct path includes '/data/' to access the KV v2 API. The template accesses .Data.data.config to get the value. This is the correct syntax for KV v2 secrets.
Why this answer
KV v2 secrets require the path to include '/data/' and the secret data is nested under .Data.data. The template function 'secret' is used with the full path, and the value is accessed via .Data.data.<key>. This ensures correct retrieval and rendering.
Exam trap
The trap here is mixing KV v1 and v2 path structures and data nesting, which often leads to missing secrets.