Trying to use looped outputs of a module in another module/loop #14653
-
Hey team, I am trying to create a storage account, with private endpoints (for blob, table, web, queue and file), and then create the relevant DNS entries for them. The reason I have to modulate these is the privateendpoints and privatedns live in different resource groups/subscriptions.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You need to do the loop: module aRecord '../Module-PrivateDNS-A.bicep' = [for i in storageInfo:{
name: '${storageAccountName}-aRecord-${i}'
scope: resourceGroup(dnsRG)
params: {
endpointName: storageAccountName
dnsZoneName: 'privatelink.${i.groupid}.${az.environment().suffixes.storage}'
privateEndpointIpAddress: i.dnsip
}
}] Inside a module that is referenced in the main.bicep as explained by the error Or if you already know the value of param storageTypes array
...
module aRecord './Module-PrivateEndpoint-Storagev2.bicep' = [for i in range(0, length(storageTypes)):{
name: '${storageAccountName}-aRecord-${i}'
scope: resourceGroup(dnsRG)
params: {
endpointName: storageAccountName
dnsZoneName: 'privatelink.${storageInfo[i].groupid}.${az.environment().suffixes.storage}'
privateEndpointIpAddress: storageInfo[i].dnsip
}
}]
|
Beta Was this translation helpful? Give feedback.
-
So I was able to get this working. I was overthinking this, and just needed to pass the array into the module, and let the module handle the information from there. Most of the changes happened in the DNS module at the bottom.
Here is my main.bicep:
Module-PrivateEndpoint-Storagev2.bicep:
Module-PrivateDNS-A.bicep
I hope this is able to help someone with bicep storage accounts, with private endpoint and the azure dns records to go with them. |
Beta Was this translation helpful? Give feedback.
So I was able to get this working. I was overthinking this, and just needed to pass the array into the module, and let the module handle the information from there. Most of the changes happened in the DNS module at the bottom.
Her…