From e7dba3e55eec9cfc50f75006a9bc34e6ee159b4e Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Tue, 17 Mar 2020 13:32:36 -0700 Subject: [PATCH] fix error cleaning up existing keyvault --- builder/azure/arm/builder.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index c891d3fe1..54cb8eee2 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -228,11 +228,11 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack NewStepDeleteAdditionalDisks(azureClient, ui), } } else if b.config.OSType == constants.Target_Windows { - keyVaultDeploymentName := b.stateBag.Get(constants.ArmKeyVaultDeploymentName).(string) steps = []multistep.Step{ NewStepCreateResourceGroup(azureClient, ui), } if b.config.BuildKeyVaultName == "" { + keyVaultDeploymentName := b.stateBag.Get(constants.ArmKeyVaultDeploymentName).(string) steps = append(steps, NewStepValidateTemplate(azureClient, ui, &b.config, GetKeyVaultDeployment), NewStepDeployTemplate(azureClient, ui, &b.config, keyVaultDeploymentName, GetKeyVaultDeployment), @@ -399,7 +399,7 @@ func (b *Builder) configureStateBag(stateBag multistep.StateBag) { stateBag.Put(constants.ArmComputeName, b.config.tmpComputeName) stateBag.Put(constants.ArmDeploymentName, b.config.tmpDeploymentName) - if b.config.OSType == constants.Target_Windows { + if b.config.OSType == constants.Target_Windows && b.config.BuildKeyVaultName == "" { stateBag.Put(constants.ArmKeyVaultDeploymentName, fmt.Sprintf("kv%s", b.config.tmpDeploymentName)) }