Forgive me as this is more an ARM template issue combined with a terraform limitation. We have an arm template with the following outputs (static list of managed identities):
"outputs": {
"managedIdentity1": {
"condition": "[if(greaterOrEquals(variables('webAppCountNum'), 1), bool('true'), bool('false'))]",
"type": "string",
"value": "[reference(variables('managedIdentities').managedIdentity[0].name, '2016-08-01', 'Full').identity.principalId]"
},
"managedIdentity2": {
"condition": "[if(greaterOrEquals(variables('webAppCountNum'), 2), bool('true'), bool('false'))]",
"type": "string",
"value": "[reference(variables('managedIdentities').managedIdentity[1].name, '2016-08-01', 'Full').identity.principalId]"
},
"managedIdentity3": {
"condition": "[if(greaterOrEquals(variables('webAppCountNum'), 3), bool('true'), bool('false'))]",
"type": "string",
"value": "[reference(variables('managedIdentities').managedIdentity[2].name, '2016-08-01', 'Full').identity.principalId]"
}
//continues,
I’d like to refactor this to be a dynamic list that will match the webAppCountNum. I believe I can accomplish this using output iteration, although there might be an issue using the reference function with count (haven’t tested yet):
from msdoc
You can’t use it with count because the count must be determined before the reference function is resolved.
there is also a separate issue where terraform can only access scalar outputs
with all these limitations…
is there a way to generate this dynamic output list and have it be consumable by terraform?
My idea was to convert the output array into a comma delimited string and have terraform split the data, but the restrictions on the “reference” function limit its use. If i could generate the array, i could probably convert it using this method