How to test image

After generating a image, is there any packer command available to test it? Or is there any other suggestions to test this image?

Thank you.


This depends what you mean by “test it”. Do you want to check some final state of the applied configuration? Do you want to perform functional tests of the image in a deployed environment? Do you want to check whether a regression or a vulnerability has been introduced? These are all forms of testing, with different tools in different ways.

The general answer is probably “use a provisioner” . Some examples:

  • There is the Inspec provisioner which can apply a compliance profile.
  • You could also apply a compliance or configuration check with Ansible using the Ansible provisioner
  • something like TestInfra via a local shell provisoiner
  • a vulnerability scan can be run with something like Trivy with a shell provisioner

Or you could use Terratest to implement an end-to-end test of the template.