Hello Divsalar, Ben,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you would like to have an advice on any options or enhancements for handling encryption key management via Azure API within IaC frameworks.
To meet your goals of secure, automated client-side encryption key management in Cosmos DB, within IaC framework:
- Leverage Azure Key Vault with GitHub OIDC Integration.
- Setup Key Management in Azure Key Vault:
- Store and manage Cosmos DB client-side encryption keys in Key Vault.
- Use Azure Key Vault REST API to manage keys programmatically in Pulumi.
- Use GitHub OIDC for Secure Authentication:
- Configure GitHub Actions to authenticate directly with Azure using OIDC.
- Grant the GitHub Action runner access only to Key Vault (via Azure Role Assignments like
Key Vault Secrets User
). - For more details and how to: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect and https://colinsalmcorner.com/actions-authenticate-to-azure-without-a-secret
- Use Pulumi to orchestrate the entire process, leveraging the Azure Key Vault and Cosmos DB REST APIs.
- Define Pulumi resources for Key Vault integration and ensure encryption keys are passed securely during Cosmos DB setup.
- Enforce Principle of Least Privilege.
- Restrict GitHub Action runner to access only Key Vault, without granting direct Cosmos DB access.
- For Cosmos DB encryption setup, rely on Pulumi to configure resources without persistent RBAC exposure to GitHub.
- Enforce a policy to ensure Cosmos DB instances are always configured with customer-managed keys from Key Vault, increasing security and compliance.
I think this should be a best approach that balances security, automation, and flexibility without requiring excessive privileges for GitHub runners or introducing SDK dependencies.
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.