- Unzip example.zip from https://www.dropbox.com/s/2yd3d8d642cotc0/example.zip?dl=0
- Update main.tf file to include
tenant_idandsubscription_idvalues for an Azure subscription az login --tenant <tenant_id>terraform initterraform apply, which creates the base of the example resources:
example-rgresource groupexample-vnetvirtual networksubnet1subnet (with Storage and Key Vault service endpoints)exampleXXXXXXXXXstorage accountexampleXXXXXXXXXkey vault
The purpose of this test is to show that when adding a subnet and using concat(), both Storage Account and Key Vault virtual network subnet ids are updated with the new subnet.
Before beginning review the main.tf in the region module folder. Note the virtual_network_subnet_ids property of the storage account and key vault resources is using a concat() function to combine a for value in and list(string) object.
- Uncomment
subnet2definition inconfig.auto.tfvarsfile terraform plan
Note 1 resource will be added (subnet2), and 2 resources will be updated (storage account and key vault virtual network subnet ids). This is expected behavior.
The purpose of this test is to show that when adding a subnet and using concat() and distinct(), only the Key Vault virtual network subnet ids are updated with the new subnet. The Storage Account virtual network subnet ids do not detect a change.
- Open the
main.tffile in theregionmodule folder. - Uncomment the
Test 2scenariovirtual_network_subnet_idsproperty for the Storage Account and Key Vault terraform plan
Note 1 resource will be added (subnet2), and only 1 resource will be updated (the key vault). This behavior is unexpected. The expected behavior it to see 2 resources updated (the storage account and the key vault).
The purpose of these tests is to show that when distinct() and compact() are used, only the Key Vault virtual network subnet ids are updated with the new subnet. The Storage Account virtual network subnet ids do not detect a change.
Follow the same process as test 2 to see the same results.