How can I intergrade packer output image id(Azure) to terraform variables automatically?

I’m using packer with ansible provisioner to build an azure image, and terraform to set up the infrastructure with that azure image as a source

When command packer build pack.json completes successfully I get the output image id and URL

In my terraform variables I need to specify the source image id, region etc. The problem here is that I don’t want to specify them manually or multiple times. For region (that I know beforehand) it’s easy since I can use environment variables in both situations, but what about the output image? Is there a built-in way to chain these products or some not so hacky approach to do it?

You can store the image id and other data in a manifest file using the manifest post-processor, and then parse the data from there. We’re working on a pipelineing tool (HCP Packer registry) that will make this integration much easier; more news to come on that front pretty soon.