able-caravan-56262
08/25/2025, 9:33 AMpulumi up --refresh be enough to detect and import the restored secret so that it can be managed again?
In my case, the secret is used in CD pipeline Helm , so I don't want to change the secret name.
After my experiments soft deleted KeyVault are handled by default, but secrets notlittle-cartoon-10569
08/25/2025, 8:19 PMpulumi import to resolve this, but it's probably easier to just add the import opt to the code for the secret, with the import id as specified in the secret's Pulumi docs (near the bottom, there should be a heading "Import", which tells you what the import id for that type of resource is).
Once you've got the import opt in there, you can run a pulumi up and Pulumi will link the state with the deployed resource in the provider.
Once you've got them linked, don't forget to remove the import opt. If you leave it in, you'll get warnings, and occasionally Pulumi might get confused and attempted to re-import that resource. Always safest to remove the import ids.able-caravan-56262
08/25/2025, 9:08 PMpulumi up --refresh, but it didn’t work as expected.little-cartoon-10569
08/25/2025, 9:13 PMable-caravan-56262
08/25/2025, 9:20 PMlittle-cartoon-10569
08/25/2025, 9:23 PMable-caravan-56262
08/25/2025, 9:29 PMlittle-cartoon-10569
08/25/2025, 9:39 PMable-caravan-56262
08/25/2025, 9:41 PMlittle-cartoon-10569
08/25/2025, 9:42 PMsteep-plastic-74107
08/25/2025, 10:13 PMconst afterDelete = new pulumi.ResourceHook("after", async () => {
console.log("Waiting for secret deletion to complete before purging...");
const credential = new DefaultAzureCredential();
const vaultUrl = `<https://elisabethtest-kv.vault.azure.net/>`;
const client = new SecretClient(vaultUrl, credential);
// Wait for the secret to be fully deleted before purging
const maxRetries = 30;
const retryDelay = 2000; // 2 seconds
for (let i = 0; i < maxRetries; i++) {
try {
// Check if secret is in deleted state (not being deleted)
await client.getDeletedSecret("elisabethtest");
console.log("Secret is now in deleted state, proceeding with purge...");
await client.purgeDeletedSecret("elisabethtest");
console.log("Secret purged successfully");
return;
} catch (error: any) {
if (error.code === "ObjectIsBeingDeleted") {
console.log(`Attempt ${i + 1}: Secret still being deleted, waiting...`);
await new Promise((resolve) => setTimeout(resolve, retryDelay));
continue;
} else if (error.code === "SecretNotFound") {
console.log("Secret not found in deleted state, may already be purged");
continue;
} else {
console.warn("Failed to purge secret:", error.message);
return;
}
}
}
console.warn("Timeout waiting for secret deletion to complete");
});
// Create or import an Azure Key Vault secret
const keyVaultSecret = new azure.keyvault.Secret(
"elisabethtest",
{
resourceGroupName: resourceGroup.name,
vaultName: keyVault.name,
secretName: "elisabethtest",
properties: {
value: "elisabeth-secret-value",
},
},
{
hooks: {
afterDelete: [afterDelete],
},
}
);steep-plastic-74107
08/25/2025, 10:14 PM