-
Notifications
You must be signed in to change notification settings - Fork 140
feat (iac): [secure-hybrid-network] add e2e validation and DNAT rules #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b09b89f
add e2e validation steps via VPN tunnel
ferantivero 77281b6
fix DNAT validation with separate v2 deployment step
ferantivero 51e092e
Address PR Feedback: preserve base FW rules and use WindowsUpdate FQD…
ferantivero 3afe32e
Merge branch 'main' into feature/421252_add-validation-steps
ckittel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
solutions/secure-hybrid-network/nestedtemplates/azure-network-azuredeploy-v2.bicep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| // Once an on-premises site joins the network, this template updates the hub | ||
| // firewall with a DNAT rule so inbound traffic can reach the spoke workloads. | ||
|
|
||
| param location string = resourceGroup().location | ||
|
|
||
| @description('Name of the Azure Firewall') | ||
| param firewallName string | ||
|
|
||
| @description('Private IP address of the firewall') | ||
| param firewallPrivateIp string | ||
|
|
||
| @description('Private IP address of the internal load balancer') | ||
| param internalLoadBalancerPrivateIp string | ||
|
|
||
| @description('Name of the hub virtual network') | ||
| param hubVnetName string = 'vnet-hub' | ||
|
|
||
| @description('Name of the firewall public IP') | ||
| param firewallPublicIpName string = 'pip-firewall' | ||
|
|
||
| @description('Spoke network address prefix for source filtering') | ||
| param spokeAddressPrefix string = '10.100.0.0/16' | ||
|
|
||
| resource hubVnet 'Microsoft.Network/virtualNetworks@2024-05-01' existing = { | ||
| name: hubVnetName | ||
| } | ||
|
|
||
| resource firewallPublicIp 'Microsoft.Network/publicIPAddresses@2024-05-01' existing = { | ||
| name: firewallPublicIpName | ||
| } | ||
|
|
||
| resource firewallDnat 'Microsoft.Network/azureFirewalls@2024-05-01' = { | ||
| name: firewallName | ||
| location: location | ||
| properties: { | ||
| sku: { | ||
| name: 'AZFW_VNet' | ||
| tier: 'Standard' | ||
| } | ||
| threatIntelMode: 'Alert' | ||
| ipConfigurations: [ | ||
| { | ||
| name: firewallName | ||
| properties: { | ||
| publicIPAddress: { | ||
| id: firewallPublicIp.id | ||
| } | ||
| subnet: { | ||
| id: resourceId('Microsoft.Network/virtualNetworks/subnets', hubVnet.name, 'AzureFirewallSubnet') | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| applicationRuleCollections: [ | ||
| { | ||
| name: 'spoke-outbound' | ||
| properties: { | ||
| priority: 100 | ||
| action: { | ||
| type: 'Allow' | ||
| } | ||
| rules: [ | ||
| { | ||
| name: 'all-internet' | ||
| protocols: [ | ||
| { | ||
| protocolType: 'Http' | ||
| port: 80 | ||
| } | ||
| { | ||
| protocolType: 'Https' | ||
| port: 443 | ||
| } | ||
| ] | ||
| targetFqdns: [ | ||
| '*' | ||
| ] | ||
| sourceAddresses: [ | ||
| '*' | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| { | ||
| name: 'spoke-windows-update' | ||
| properties: { | ||
| priority: 200 | ||
| action: { | ||
| type: 'Allow' | ||
| } | ||
| rules: [ | ||
| { | ||
| name: 'windows-update' | ||
| fqdnTags: [ | ||
| 'WindowsUpdate' | ||
| ] | ||
| sourceAddresses: [ | ||
| spokeAddressPrefix | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| natRuleCollections: [ | ||
| { | ||
| name: 'dnat-onprem-to-spoke' | ||
| properties: { | ||
| priority: 100 | ||
| action: { | ||
| type: 'Dnat' | ||
| } | ||
| rules: [ | ||
| { | ||
| name: 'onprem-to-web' | ||
| protocols: [ | ||
| 'TCP' | ||
| ] | ||
| sourceAddresses: [ | ||
| '192.168.0.0/16' | ||
| ] | ||
| destinationAddresses: [ | ||
| firewallPrivateIp | ||
| ] | ||
| destinationPorts: [ | ||
| '80' | ||
| ] | ||
| translatedAddress: internalLoadBalancerPrivateIp | ||
| translatedPort: '80' | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
166 changes: 166 additions & 0 deletions
166
solutions/secure-hybrid-network/nestedtemplates/azure-network-azuredeploy-v2.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| { | ||
| "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
| "contentVersion": "1.0.0.0", | ||
| "metadata": { | ||
| "_generator": { | ||
| "name": "bicep", | ||
| "version": "0.39.26.7824", | ||
| "templateHash": "11434533286408150086" | ||
| } | ||
| }, | ||
| "parameters": { | ||
| "location": { | ||
| "type": "string", | ||
| "defaultValue": "[resourceGroup().location]" | ||
| }, | ||
| "firewallName": { | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "Name of the Azure Firewall" | ||
| } | ||
| }, | ||
| "firewallPrivateIp": { | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "Private IP address of the firewall" | ||
| } | ||
| }, | ||
| "internalLoadBalancerPrivateIp": { | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "Private IP address of the internal load balancer" | ||
| } | ||
| }, | ||
| "hubVnetName": { | ||
| "type": "string", | ||
| "defaultValue": "vnet-hub", | ||
| "metadata": { | ||
| "description": "Name of the hub virtual network" | ||
| } | ||
| }, | ||
| "firewallPublicIpName": { | ||
| "type": "string", | ||
| "defaultValue": "pip-firewall", | ||
| "metadata": { | ||
| "description": "Name of the firewall public IP" | ||
| } | ||
| }, | ||
| "spokeAddressPrefix": { | ||
| "type": "string", | ||
| "defaultValue": "10.100.0.0/16", | ||
| "metadata": { | ||
| "description": "Spoke network address prefix for source filtering" | ||
| } | ||
| } | ||
| }, | ||
| "resources": [ | ||
| { | ||
| "type": "Microsoft.Network/azureFirewalls", | ||
| "apiVersion": "2024-05-01", | ||
| "name": "[parameters('firewallName')]", | ||
| "location": "[parameters('location')]", | ||
| "properties": { | ||
| "sku": { | ||
| "name": "AZFW_VNet", | ||
| "tier": "Standard" | ||
| }, | ||
| "threatIntelMode": "Alert", | ||
| "ipConfigurations": [ | ||
| { | ||
| "name": "[parameters('firewallName')]", | ||
| "properties": { | ||
| "publicIPAddress": { | ||
| "id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('firewallPublicIpName'))]" | ||
| }, | ||
| "subnet": { | ||
| "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('hubVnetName'), 'AzureFirewallSubnet')]" | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "applicationRuleCollections": [ | ||
| { | ||
| "name": "spoke-outbound", | ||
| "properties": { | ||
| "priority": 100, | ||
| "action": { | ||
| "type": "Allow" | ||
| }, | ||
| "rules": [ | ||
| { | ||
| "name": "all-internet", | ||
| "protocols": [ | ||
| { | ||
| "protocolType": "Http", | ||
| "port": 80 | ||
| }, | ||
| { | ||
| "protocolType": "Https", | ||
| "port": 443 | ||
| } | ||
| ], | ||
| "targetFqdns": [ | ||
| "*" | ||
| ], | ||
| "sourceAddresses": [ | ||
| "*" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "name": "spoke-windows-update", | ||
| "properties": { | ||
| "priority": 200, | ||
| "action": { | ||
| "type": "Allow" | ||
| }, | ||
| "rules": [ | ||
| { | ||
| "name": "windows-update", | ||
| "fqdnTags": [ | ||
| "WindowsUpdate" | ||
| ], | ||
| "sourceAddresses": [ | ||
| "[parameters('spokeAddressPrefix')]" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ], | ||
|
ferantivero marked this conversation as resolved.
|
||
| "natRuleCollections": [ | ||
| { | ||
| "name": "dnat-onprem-to-spoke", | ||
| "properties": { | ||
| "priority": 100, | ||
| "action": { | ||
| "type": "Dnat" | ||
| }, | ||
| "rules": [ | ||
| { | ||
| "name": "onprem-to-web", | ||
| "protocols": [ | ||
| "TCP" | ||
| ], | ||
| "sourceAddresses": [ | ||
| "192.168.0.0/16" | ||
| ], | ||
| "destinationAddresses": [ | ||
| "[parameters('firewallPrivateIp')]" | ||
| ], | ||
| "destinationPorts": [ | ||
| "80" | ||
| ], | ||
| "translatedAddress": "[parameters('internalLoadBalancerPrivateIp')]", | ||
| "translatedPort": "80" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.