将另一个文件中的对象包含到主二头肌模板中

时间:2021-06-11 23:42:54

标签: azure-bicep

尝试做某事,我不知道是否可行,如果可行,我正在寻求有关如何去做的帮助。

我有一个包含对象的文件“test.bicep”:

{
  name: 'testRafaelRule'
  priority: 1001
  ruleCollectionType: 'FirewallPolicyFilterRuleCollection'
  action: {
    type: 'Allow'
  }
  rules: [
    {
      name: 'deleteme-1'
      ipProtocols: [
        'Any'
      ]
      destinationPorts: [
        '*'
      ]
      sourceAddresses: [
        '192.168.0.0/16'
      ]
      sourceIpGroups: []
      destinationIpGroups: []
      destinationAddresses: [
        'AzureCloud.EastUS'
      ]            
      ruleType: 'NetworkRule'
      destinationFqdns: []
    }
  ]
}

我还有另一个文件,我试图在其中以某种方式将 test.bicep 中的对象输入到名为“ruleCollections”的特定属性中:

resource fwll 'Microsoft.Network/firewallPolicies/ruleCollectionGroups@2020-11-01' = {  
  name: 'netrules'  
  properties: {
    priority: 200
    ruleCollections: [
      **ADD_OBJECT_FROM_TEST.BICEP_HERE_HOW?**
    ]
  }
}

任何建议或有用文档的链接都会有所帮助。 我查看了输出和参数,但我只是尝试将一个对象添加到现有属性中,我不会自行添加整个资源,否则,我将输出资源并使用“模块”关键字使用它。

1 个答案:

答案 0 :(得分:1)

这不可能简单明了,但您可以利用变量或模块的输出。

var RULE = {
  name: 'testRafaelRule'
  priority: 1001
(...)
}

resource fwll 'Microsoft.Network/firewallPolicies/ruleCollectionGroups@2020-11-01' = {  
 name 'netrules'
 properties: {
  ruleCollections: [ 
   RULE
  ]
 }
}

规则.二头肌

output rule object = {
  name: 'testRafaelRule'
  priority: 1001
(...)
}

main.bicep

module fwrule 'rule.bicep' = {
 name: 'fwrule'
}
resource fwll 'Microsoft.Network/firewallPolicies/ruleCollectionGroups@2020-11-01' = {  
 name 'netrules'
 properties: {
  ruleCollections: [ 
   fwrule.outputs.rule
  ]
 }
}
相关问题