Add support for the Azure Image Builder service (currently in late preview), to automatically build VHDs (or managed/shared images?) from Packer templates, which can then be used by the azurerm_image
or azurerm_shared_image
resources.
The goal would be to remove the manual image creation and upload step from the workflow described in Create a private Azure Pipeline Agent using Packer, Terraform and Ansible.
resource "azurerm_image_template" "template" {
# Should some accommodation be made for embedded Packer templates,
# or uploading to remote storage from local filesystem?
template_uri = "PACKER_IMAGE_PATH"
}
resource "azurerm_image" "image" {
source_template_id = "${azurerm_image_template.template.id}"
}
resource "azurerm_virtual_machine" "vm" {
storage_image_reference {
id = "${azurerm_image.image.id}"
}
Refs https://github.com/terraform-providers/terraform-provider-azurerm/issues/164
remote-exec
provisioner implicitly to build the image if necessary when an image template is referenced as a source for an image? (Starting the image build seems to require an explicit invocation.)I'm working on this.
@mybayern1974 any luck with the progress on this?
I submitted a PR to support this Azure resource. However I did not think of an elegant way to support the preference the issue raised:
resource "azurerm_image" "image" {
source_template_id = azurerm_image_template.template.id
}
Because:
template
resource rather than its actual distribution resources that can only be generated after a RUN action. While those generated resources become out of control of Terraform that just manages this template resource.So the current implementation is to have Terraform manage this template resource and leave post execution outside of Terraform.