Is it possible to pass optional module parameter conditionally only? #5606
-
|
Hi there Is it possibile to pass a parameter to a module conditionally by using the ternary operator so that when passe the passed value is used and other wises the default value specified in the module? The idea is to have a default value in a module and if the parameter is not defined during deployment the default is used and otherwise the value specified is used. So the default value can be defined inside of the module but can be overwritten if needed. To make it maybe more clear here an example what I mean: The module has defined a parameter with type param ipsecPolices object = {
SALifeTimeSeconds: 27000
SADataSizeKilobytes: 102400000
IpsecEncryption: 'AES256'
IpsecIntegrity: 'SHA256'
IkeEncryption: 'AES256'
IkeIntegrity: 'SHA256'
DhGroup: 'DHGroup14'
PfsGroup: 'PFS2048'
}
resource vpnConnection 'Microsoft.Network/connections@2020-11-01' = {
name: name
location: location
properties: {
connectionType: 'IPsec'
sharedKey: preSharedKey
ipsecPolicies: [
ipsecPolices
]
}
}In the main template I have then tried the following: param ipsecPolices object = {}
module testmodule 'modules/testmodule.bicep' = {
name: 'deploytestmodule'
params: {
ipsecPolices : empty(ipsecPolices ) ? null : ipsecPolices
}
}But this does not work because: Is this somehow possibile? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
The solution for this may depend on a few things... Some things to consider...
ipsecPolices : empty(ipsecPolices ) ? {} : ipsecPolices
param ipsecPolices object = {} |
Beta Was this translation helpful? Give feedback.
The solution for this may depend on a few things...
Some things to consider...