From f3c0f9c129cc3cb51908be3b944445b28a6b6d65 Mon Sep 17 00:00:00 2001 From: vishal anand Date: Mon, 26 Apr 2021 20:06:18 +0530 Subject: [PATCH] Getting below mentioned error on azure_key_vault table. Closes #103 --- azure/table_azure_key_vault.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/azure/table_azure_key_vault.go b/azure/table_azure_key_vault.go index a9fb548b..978387f1 100644 --- a/azure/table_azure_key_vault.go +++ b/azure/table_azure_key_vault.go @@ -249,7 +249,7 @@ func getKeyVault(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData func listKmsKeyVaultDiagnosticSettings(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { plugin.Logger(ctx).Trace("listKmsKeyVaultDiagnosticSettings") - data := h.Item.(keyvault.Vault) + id := getKeyVaultID(h.Item) // Create session session, err := GetNewSession(ctx, d, "MANAGEMENT") @@ -261,7 +261,7 @@ func listKmsKeyVaultDiagnosticSettings(ctx context.Context, d *plugin.QueryData, client := insights.NewDiagnosticSettingsClient(subscriptionID) client.Authorizer = session.Authorizer - op, err := client.List(ctx, *data.ID) + op, err := client.List(ctx, id) if err != nil { return nil, err } @@ -287,3 +287,13 @@ func listKmsKeyVaultDiagnosticSettings(ctx context.Context, d *plugin.QueryData, } return diagnosticSettings, nil } + +func getKeyVaultID(item interface{}) string { + switch item.(type) { + case keyvault.Vault: + return *item.(keyvault.Vault).ID + case keyvault.Resource: + return *item.(keyvault.Resource).ID + } + return "" +}