Skip to content

FEAT: Added KeyVaultSecret Datasource #516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

tanmay-hc
Copy link
Contributor

@tanmay-hc tanmay-hc commented Jul 21, 2025

This pull request introduces a new Key Vault data source for the Azure Packer plugin, enabling users to retrieve secrets from Azure Key Vault.

  • vault_name [required]
  • secret_name [required]
  • version

NOTE: Unlike the rest of the plugin, which uses the Hashicorp's go-azure-sdk, this change uses Azure's own sdk. This is done since the Hashicorp's azure sdk does not provide a support for fetching the value of the secret and only uses the ARM APIs, which only provides us with the properties of the secret and not the value.

Closes #71

@tanmay-hc tanmay-hc force-pushed the keyvault-datasource branch from 3ae5b90 to 6a80f58 Compare July 22, 2025 12:07
@tanmay-hc tanmay-hc marked this pull request as ready for review July 22, 2025 12:19
@tanmay-hc tanmay-hc requested a review from a team as a code owner July 22, 2025 12:19
@tanmay-hc tanmay-hc changed the title [WIP]: Added KeyVault Datasource Jul 22, 2025
@tanmay-hc tanmay-hc marked this pull request as draft July 22, 2025 12:52
@tanmay-hc tanmay-hc force-pushed the keyvault-datasource branch from 906d6f8 to 0e18857 Compare July 24, 2025 08:54
@tanmay-hc tanmay-hc marked this pull request as ready for review July 24, 2025 09:04
@tanmay-hc tanmay-hc changed the title FEAT: Added KeyVault Datasource Jul 24, 2025
@tanmay-hc tanmay-hc force-pushed the keyvault-datasource branch from d9d3324 to 2b415f7 Compare July 28, 2025 02:50
Copy link
Collaborator

@JenGoldstrich JenGoldstrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work Tanmay, this is looking really good. I think we need to re-think some of the authentication logic and bring it more in line with the how the builders work, as I think this will be a better user experience, please let me know what you think!


client_id = var.client_id
client_secret = var.client_secret
tenant_id = var.tenant_id
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add subscription_id here after the changes to use the existing authorizer

Comment on lines +18 to +20
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/keyvault/azsecrets"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need to use the azure-sdk-for-go here? I assume you just haven't updated this acceptance test since migrating to the new strategy for solving this

@@ -52,6 +52,25 @@ resource "azurerm_shared_image" "linux-sig" {
}
}

resource "azurerm_key_vault" "vault" {
name = "packer-acctest-vault"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now if two developers are working on the plugin, or if CI is running when a developer is working, this can cause conflict, you should use the resource prefix for resources that have unique name across subscription, which I think key vaults are at least subscription wide for unique names, since we ran into that error before

Suggested change
name = "packer-acctest-vault"
name = "${var.resource_prefix}-pkr-test-vault"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants