diff --git a/.web-docs/components/builder/arm/README.md b/.web-docs/components/builder/arm/README.md index 5e56f6bc..64138a59 100644 --- a/.web-docs/components/builder/arm/README.md +++ b/.web-docs/components/builder/arm/README.md @@ -765,6 +765,8 @@ post-processor "manifest" { strip_path = true custom_data = { source_image_name = "${build.SourceImageName}" + tenant_id = "${build.TenantID}" + subscription_id = "${build.SubscriptionID}" } } ``` @@ -777,7 +779,9 @@ post-processor "manifest" { "output": "manifest.json", "strip_path": true, "custom_data": { - "source_image_name": "{{ build `SourceImageName` }}" + "source_image_name": "{{ build `SourceImageName` }}", + "tenant_id": "{{ build `TenantID` }}", + "subscription_id": "{{ build `SubscriptionID` }}" } } ] diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index 874c50a3..868817f4 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -390,10 +390,6 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) ) } steps = append(steps, - &StepSetGeneratedData{ - GeneratedData: generatedData, - Config: &b.config, - }, NewStepValidateTemplate(azureClient, ui, &b.config, deploymentName, getVirtualMachineDeploymentFunction), NewStepDeployTemplate(azureClient, ui, &b.config, deploymentName, getVirtualMachineDeploymentFunction, VirtualMachineTemplate), NewStepGetIPAddress(azureClient, ui, endpointConnectType), @@ -440,7 +436,12 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) NewStepCaptureImage(azureClient, ui), NewStepPublishToSharedImageGallery(azureClient, ui, &b.config), ) - + steps = append([]multistep.Step{ + &StepSetGeneratedData{ + GeneratedData: generatedData, + Config: &b.config, + }, + }, steps...) steps = append(steps, captureSteps...) if b.config.PackerDebug { diff --git a/builder/azure/arm/testdata/arm_linux_specialized.pkr.hcl b/builder/azure/arm/testdata/arm_linux_specialized.pkr.hcl index fa4624f8..6ebe9df6 100644 --- a/builder/azure/arm/testdata/arm_linux_specialized.pkr.hcl +++ b/builder/azure/arm/testdata/arm_linux_specialized.pkr.hcl @@ -38,5 +38,15 @@ source "azure-arm" "linux-sig" { build { sources = ["source.azure-arm.linux-sig"] + post-processor "manifest" { + output = "manifest.json" + strip_path = true + custom_data = { + source_image_name = "${build.SourceImageName}" + tenant_id = "${build.TenantID}" + subscription_id = "${build.SubscriptionID}" + } +} + } diff --git a/docs/builders/arm.mdx b/docs/builders/arm.mdx index e175e1c1..590b669e 100644 --- a/docs/builders/arm.mdx +++ b/docs/builders/arm.mdx @@ -178,6 +178,8 @@ post-processor "manifest" { strip_path = true custom_data = { source_image_name = "${build.SourceImageName}" + tenant_id = "${build.TenantID}" + subscription_id = "${build.SubscriptionID}" } } ``` @@ -190,7 +192,9 @@ post-processor "manifest" { "output": "manifest.json", "strip_path": true, "custom_data": { - "source_image_name": "{{ build `SourceImageName` }}" + "source_image_name": "{{ build `SourceImageName` }}", + "tenant_id": "{{ build `TenantID` }}", + "subscription_id": "{{ build `SubscriptionID` }}" } } ]