Skip to content

Commit 0092ba2

Browse files
committed
fix: Updated the code with required changes
1 parent 3bb8e99 commit 0092ba2

File tree

4 files changed

+40
-49
lines changed

4 files changed

+40
-49
lines changed

examples/complete/example.tf

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ provider "azurerm" {
55
locals {
66
name = "app"
77
environment = "test"
8+
# Define public IPs as a local variable for reusability
9+
public_ip_names = ["vnet", "app"]
810
}
9-
1011
##-----------------------------------------------------------------------------
1112
## Resource Group module call
1213
## Resource group in which all resources will be deployed.
@@ -89,15 +90,14 @@ module "log-analytics" {
8990
## All firewall related resources will be deployed from this module, i.e. including firewall and firewall rules.
9091
##-----------------------------------------------------------------------------
9192
module "firewall" {
92-
depends_on = [module.name_specific_subnet]
93-
source = "../.."
94-
name = local.name
95-
environment = local.environment
96-
resource_group_name = module.resource_group.resource_group_name
97-
location = module.resource_group.resource_group_location
98-
subnet_id = module.name_specific_subnet.subnet_ids["AzureFirewallSubnet"]
99-
primary_public_ip_name = "ingress"
100-
public_ip_names = ["vnet", "app-4", "aap-1", "app-2"]
93+
depends_on = [module.name_specific_subnet]
94+
source = "../.."
95+
name = local.name
96+
environment = local.environment
97+
resource_group_name = module.resource_group.resource_group_name
98+
location = module.resource_group.resource_group_location
99+
subnet_id = module.name_specific_subnet.subnet_ids["AzureFirewallSubnet"]
100+
public_ip_names = local.public_ip_names
101101
firewall_enable = true
102102
public_ip_prefix_enable = true
103103
public_ip_prefix_length = 28
@@ -144,7 +144,7 @@ module "firewall" {
144144
network_rule_collection = [
145145
{
146146
name = "example_network_policy"
147-
priority = "100"
147+
priority = 100
148148
action = "Allow"
149149
rules = [
150150
{
@@ -182,11 +182,11 @@ module "firewall" {
182182
{
183183
name = "web_server_nat"
184184
protocols = ["TCP"]
185-
source_addresses = ["*"] # Any source
186-
destination_address = module.firewall.primary_public_ip_address # Your firewall's PUBLIC IP
187-
destination_ports = ["8080"] # External port
188-
translated_address = "10.0.1.20" # Internal server IP
189-
translated_port = "80" # Internal port
185+
source_addresses = ["*"] # Any source
186+
destination_address = module.firewall.public_ip_addresses["vnet"] # Your firewall's PUBLIC IP
187+
destination_ports = ["8080"] # External port
188+
translated_address = "10.0.1.20" # Internal server IP
189+
translated_port = "80" # Internal port
190190
}
191191
]
192192
}

examples/complete/outputs.tf

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,3 @@ output "public_ip_address" {
1111
value = module.firewall.public_ip_addresses
1212
description = "The public IP address associated with the firewall"
1313
}
14-
15-
output "primary_public_ip_id" {
16-
value = module.firewall.primary_public_ip_id
17-
description = "The Primary public IP associated with the firewall"
18-
19-
}
20-
21-
output "primary_public_ip_address" {
22-
value = module.firewall.primary_public_ip_address
23-
description = "The Primary public IP address associated with the firewall"
24-
}

examples/firewall-with-isolated-rules/example.tf

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ locals {
1212
## Resource group in which all resources will be deployed.
1313
##-----------------------------------------------------------------------------
1414
module "resource_group" {
15-
source = "terraform-az-modules/resource-group/azure"
16-
version = "1.0.0"
15+
source = "../../../terraform-azure-resource-group" #"terraform-az-modules/resource-group/azure"
16+
# version = "1.0.1"
1717
name = local.name
1818
environment = local.environment
1919
label_order = ["name", "environment"]
@@ -26,8 +26,8 @@ module "resource_group" {
2626
##-----------------------------------------------------------------------------
2727
module "vnet" {
2828
depends_on = [module.resource_group]
29-
source = "terraform-az-modules/vnet/azure"
30-
version = "1.0.0"
29+
source = "../../../terraform-azure-vnet" #"terraform-az-modules/vnet/azure"
30+
#version = "1.0.0"
3131
name = local.name
3232
environment = local.environment
3333
resource_group_name = module.resource_group.resource_group_name
@@ -41,8 +41,8 @@ module "vnet" {
4141
##-----------------------------------------------------------------------------
4242
module "name_specific_subnet" {
4343
depends_on = [module.vnet]
44-
source = "terraform-az-modules/subnet/azure"
45-
version = "1.0.0"
44+
source = "../../../terraform-azure-subnet" #"terraform-az-modules/subnet/azure"
45+
#version = "1.0.0"
4646
environment = "test"
4747
label_order = ["name", "environment", ]
4848
resource_group_name = module.resource_group.resource_group_name
@@ -74,8 +74,8 @@ module "name_specific_subnet" {
7474
## Log Analytic workspace for firerwall diagnostic setting.
7575
##-----------------------------------------------------------------------------
7676
module "log-analytics" {
77-
source = "terraform-az-modules/log-analytics/azure"
78-
version = "1.0.0"
77+
source = "../../../terraform-azure-log-analytics" #"terraform-az-modules/log-analytics/azure"
78+
#version = "1.0.0"
7979
name = local.name
8080
environment = local.environment
8181
label_order = ["name", "environment", "location"]
@@ -97,7 +97,6 @@ module "firewall" {
9797
environment = local.environment
9898
resource_group_name = module.resource_group.resource_group_name
9999
location = module.resource_group.resource_group_location
100-
primary_public_ip_name = "public-ip-1"
101100
subnet_id = module.name_specific_subnet.subnet_ids["AzureFirewallSubnet"]
102101
public_ip_names = ["ingress", "vnet"] // Name of public ips you want to create.
103102
firewall_enable = true
@@ -115,13 +114,12 @@ module "firewall" {
115114
## This is same module as 'firewall module', but from this module only firewall rules and rule collection group will be deployed.
116115
##-----------------------------------------------------------------------------
117116
module "firewall-rules" {
118-
depends_on = [module.firewall]
119-
source = "../.."
120-
name = local.name
121-
environment = local.environment
122-
policy_rule_enabled = true
123-
primary_public_ip_name = module.firewall.primary_public_ip_name
124-
firewall_policy_id = module.firewall.firewall_policy_id
117+
depends_on = [module.firewall]
118+
source = "../.."
119+
name = local.name
120+
environment = local.environment
121+
policy_rule_enabled = true
122+
firewall_policy_id = module.firewall.firewall_policy_id
125123
application_rule_collection = [
126124
{
127125
name = "example_app_policy"
@@ -187,12 +185,12 @@ module "firewall-rules" {
187185
name = "nat_rule_collection1_rule1"
188186
protocols = ["TCP", "UDP"]
189187
source_addresses = ["10.0.0.1", "10.0.0.2"]
190-
destination_address = module.firewall.primary_public_ip_address
188+
destination_address = module.firewall.public_ip_addresses["vnet"]
191189
destination_ports = ["80"]
192190
translated_address = "192.168.0.1"
193191
translated_port = "8080"
194192
},
195193
]
196194
},
197195
]
198-
}
196+
}

examples/firewall-with-public-ip-prefix/example.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module "resource_group" {
2626
##-----------------------------------------------------------------------------
2727
module "vnet" {
2828
depends_on = [module.resource_group]
29-
source = "terraform-az-modules/vnet/azure"
29+
source = "terraform-azure-vnet" #"terraform-az-modules/vnet/azure"
3030
version = "1.0.0"
3131
name = local.name
3232
environment = local.environment
@@ -84,6 +84,8 @@ module "log-analytics" {
8484
location = module.resource_group.resource_group_location
8585
}
8686

87+
88+
8789
##-----------------------------------------------------------------------------
8890
## Firewall module call.
8991
## All firewall related resources will be deployed from this module, i.e. including firewall and firewall rules.
@@ -98,8 +100,10 @@ module "firewall" {
98100
subnet_id = module.name_specific_subnet.subnet_ids["AzureFirewallSubnet"]
99101
firewall_enable = true
100102
policy_rule_enabled = true
101-
primary_public_ip_name = "public-ip-1"
102-
enable_diagnostic = false
103+
public_ip_names = ["ingress", "vnet", "app", "app-2"]
104+
enable_diagnostic = true
105+
eventhub_name = local.name
106+
public_ip_prefix_enable = true
103107
log_analytics_workspace_id = module.log-analytics.workspace_id
104108

105109
application_rule_collection = [
@@ -168,7 +172,7 @@ module "firewall" {
168172
protocols = ["TCP", "UDP"]
169173
source_addresses = ["10.0.0.1", "10.0.0.2"]
170174
destination_ports = ["80"]
171-
destination_address = module.firewall.primary_public_ip_address
175+
destination_address = module.firewall.public_ip_addresses["vnet"]
172176
translated_address = "192.168.0.1"
173177
translated_port = "8080"
174178
},

0 commit comments

Comments
 (0)