My company wants to do the following process using IAC/Terraform
We have the code to create a VM in a single Azure subscription using a DevOps pipeline that uses count to be able increment or decrement the number of VMs, but we are running into an issue with rerunning the IAC/pipeline to create new IAC with different values.
Here is an example
Pipeline is run to create the following
customer1 resource group
1 customer1 VM and related resources
Again, we can add or remove VMs from this state/deployment by modifying the node_count variable we are using
Next scenario would be if we want to use the same pipeline/scripts to create new IAC for customer2
We would like to have it do the following
create customer2 resource group
x number of customer2 VMs and related resources
Right now, if have customer1 setup using something like this “terraform apply -var=“node_count=2” -var=“Customer=Customer1” -var=“NewVersion=10.1.2.0” -var=“Purpose=UAT”” and then want to run “terraform apply -var=“node_count=2” -var=“Customer=Customer2” -var=“NewVersion=10.1.2.0” -var=“Purpose=UAT”” to create IAC for customer2, it wants to destroy customer1 in order to create customer2. What is the best way to handle this, multiple statefiles in folders, workspaces, or something else? Can this be done with a single CI/CD pipeline?
Hope all this makes sense