API / APIGEE Gateway Interview Questions
What are Key Value Maps (KVMs) in Apigee and how do you use them?
Key Value Maps (KVMs) are encrypted, persistent key-value stores that allow Apigee proxies to read configuration values at runtime without hardcoding them. KVMs are ideal for storing environment-specific configuration like backend URLs, API keys, feature flags, and whitelists that need to change without redeploying proxies.
| Scope | Accessible from | Use case |
|---|---|---|
| Organisation | All proxies in the org | Global config: OAuth endpoints, universal whitelists |
| Environment | All proxies in that environment | Environment-specific: backend URLs for dev vs prod |
| Proxy | Only that specific proxy | Proxy-specific: feature flags, local config |
<!-- KeyValueMapOperations policy: GET --> <KeyValueMapOperations name="KVM.GetConfig" mapIdentifier="backend-config"> <Scope>environment</Scope> <Get assignTo="backendUrl" index="1"> <Key><Parameter>target.url</Parameter></Key> </Get> </KeyValueMapOperations> <!-- After execution, use the retrieved value --> <!-- {backendUrl} is now available in flow variables --> <!-- KeyValueMapOperations policy: PUT (write a value) --> <KeyValueMapOperations name="KVM.PutToken" mapIdentifier="token-cache"> <Scope>environment</Scope> <Put override="true"> <Key><Parameter>access_token</Parameter></Key> <Value ref="token_response.access_token"/> </Put> </KeyValueMapOperations> <!-- CLI: create a KVM and set values --> # Using Apigee API: # curl -X POST "https://apigee.googleapis.com/v1/organizations/my-org/environments/prod/keyvaluemaps" \ # -d '{"name": "backend-config", "encrypted": true}' # Add an entry: # curl -X POST ".../keyvaluemaps/backend-config/entries" \ # -d '{"name": "target.url", "value": "https://api.prod.internal.com"}'
More Related questions...