hashicorp / packer-plugin-azure

Packer plugin for Azure Virtual Machine Image Builders
https://www.packer.io/docs/builders/azure
Mozilla Public License 2.0
51 stars 80 forks source link

Use a prefix to avoid resource unique name failures in acceptance tests #398

Closed JenGoldstrich closed 6 months ago

JenGoldstrich commented 6 months ago

Recently acceptable tests in CI have been failing when I left behind some resources in the Packer team's shared test subscription, these resources, such as DTLs or Compute Galleries, have a unique name constraint on a subscription level. The way these tests were setup in https://github.com/hashicorp/packer-plugin-azure/pull/346 was done because of how Packer and Terraform handle environment variables. This leads to less confidence in actual CI failures caused by regressions.

To handle this I've introduced the ARM_RESOURCE_PREFIX environment variable, and added a script to pass variables into Terraform more cleanly, this script can be run in CI to make sure the required variables are set, and then run terraform apply with the environment variables as command line arguments.

Successful example run on this branch: https://github.com/hashicorp/packer-plugin-azure/actions/runs/8529791780/job/23367911714