@JerryMSFT - you can just clone the repo then do the following:
go to you local directory that corresponds to build/managedapp/terraform/complex/templates
create a vars file called terraform.tfvars.json that has the following values:
{"resourceGroupName":"[RESOURCEGROUP]","artifactsLocationSasToken":"","location":"eastus","sql_admin_password":"[PASSWORD]","sql_admin_username":"adminuser"}
run the following commands:
terraform init -backend=false
terraform apply -auto-approve
modify terraform.tfvars.json file so that it contains:
{"resourceGroupName":"[RESOURCEGROUP]","artifactsLocationSasToken":"","location":"eastus2","sql_admin_password":"[PASSWORD]","sql_admin_username":"adminuser"}
Re-run the following commands:
terraform init -backend=false
terraform apply -auto-approve
We want the re-deployment to succeed without error.
Summary
When executing a redeploy operation on the Terraform Complex sample, there is a failure due to the state name of the OS disk.
Reproduce
Deploy a complex terraform solution. Modify the "location" from eastus to eastus2 and execute a redeploy.
During the redeploy, there will be a failure because of the static dame of the os disk already belonging to the easy region.
The template containing the issue is located at https://github.com/microsoft/commercial-marketplace-offer-deploy/blob/main/build/managedapp/terraform/complex/templates/main.tf.
To Resolve
Create a dymamic name of the osdisk on the virtual machine. The line number should be 79.