Comprehensive and Detailed in Depth Explanation:
This question requires identifying Vault policies that allow creating a new entry with environment=prod at the specific path /secrets/apps/my_secret. Vault policies define permissions using paths, capabilities, and parameter constraints. Let’s evaluate each option:
Option A: path "secrets/+/my_secret" { capabilities = ["create"] allowed_parameters = { "*" = [] } }The + wildcard matches any single segment in the path, so this policy applies to /secrets/apps/my_secret. The create capability permits creating new entries at this path. The allowed_parameters = { "*" = [] } means any parameter (including environment) can be set to any value. This satisfies the requirement to create an entry with environment=prod. Thus, this policy is correct.
Option B: path "secrets/apps/my_secret" { capabilities = ["update"] }This policy targets the exact path /secrets/apps/my_secret but only grants the update capability. According to Vault’s documentation, update allows modifying existing entries, not creating new ones. Since the question specifies creating a new entry, this policy does not meet the requirement and is incorrect.
Option C: path "secrets/apps/my_secret" { capabilities = ["create"] allowed_parameters = { "environment" = [] } }This policy explicitly matches /secrets/apps/my_secret and grants the create capability, which allows new entries to be written. The allowed_parameters = { "environment" = [] } specifies that the environment parameter can take any value (an empty list means no restriction on values). This permits setting environment=prod, making this policy correct.
Option D: path "secrets/apps/*" { capabilities = ["create"] allowed_parameters = { "environment" = ["dev", "test", "qa", "prod"] } }The * wildcard matches any path under secrets/apps/, including /secrets/apps/my_secret. The create capability allows new entries, and the allowed_parameters restricts environment to dev, test, qa, or prod. Since prod is an allowed value, this policy permits creating an entry with environment=prod and is correct.
Overall Explanation from Vault Docs:
Vault policies control access via paths and capabilities (create, read, update, delete, list). The create capability is required to write new data. Parameter constraints (allowed_parameters) further restrict what key-value pairs can be written. An empty list ([]) allows any value, while a populated list restricts values to those specified. A deny takes precedence over any allow, but no deny is present here.
[Reference:https://developer.hashicorp.com/vault/docs/concepts/policies#parameter-constraints, ]
Submit