-
Notifications
You must be signed in to change notification settings - Fork 20
/
VnetPeerings.bicep
46 lines (42 loc) · 1.2 KB
/
VnetPeerings.bicep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
targetScope = 'subscription'
param HubResourceGroupName string
param SpokeResourceGroupName string
param HubVnetName string
param SpokeVnetName string
param HubVnetID string
param SpokeVnetID string
param counter int
param GatewayDeployed bool
param hubSubscriptionID string
param spokeSubscriptionID string
resource hubrg 'Microsoft.Resources/resourceGroups@2023-07-01' existing = {
scope: subscription(hubSubscriptionID)
name: HubResourceGroupName
}
module peeringToSpoke 'modules/vnetpeeering.bicep' = {
scope: hubrg
name: 'peeringToSpoke${counter + 1}'
params: {
peeringName: '${HubVnetName}/peeringToSpoke${counter + 1}'
remoteVnetID: SpokeVnetID
useRemoteGateways: false
allowGatewayTransit: GatewayDeployed
}
}
resource spokerg 'Microsoft.Resources/resourceGroups@2023-07-01' existing = {
scope: subscription(spokeSubscriptionID)
name: SpokeResourceGroupName
}
module peeringToHub 'modules/vnetpeeering.bicep' = {
scope: spokerg
name: 'peeringToHub${counter + 1}'
params: {
peeringName: '${SpokeVnetName}/peeringToHub${counter + 1}'
remoteVnetID: HubVnetID
useRemoteGateways: GatewayDeployed
allowGatewayTransit: false
}
dependsOn: [
peeringToSpoke
]
}