terraform-az-modules/terraform-azurerm-firewall

GitHub: terraform-az-modules/terraform-azurerm-firewall

一个用于在 Azure 平台上通过 Terraform 代码化部署和管理防火墙资源及其策略规则的模块。

Stars: 0 | Forks: 0

Banner

Terraform Azure Module Template

借助我们全面的 DevOps 工具包 —— 简化运营、自动化工作流程、加强协作,最重要的是,自信地进行部署。

Terraform Licence Changelog


我们是一群 DevOps 工程师和架构师,致力于在当今不断演变的数字环境中协作构建标准化、可扩展且安全的基础设施。我们深信自动化和模块化设计(类似于微服务)的理念,专注于将基础设施分解为更小的、可重用的组件,例如数据库、集群等。这些组件遵循行业最佳实践构建,易于管理、扩展和保护。 本代码库属于 **terraform-az-modules** 组织,提供开源、可重用的 Terraform 模块。其中包含实用的示例和工作流程,旨在帮助用户通过最少的配置和高可维护性,快速理解、实施并改进其基础设施。 ## 前置条件与 Providers 此表包含前置条件和 Providers: | Description | Name | Version | |:-------------:|:-------------------------------------------:|:---------:| | **Prerequisite** | [Terraform](https://learn.hashicorp.com/terraform/getting-started/install.html) | >= 1.6.6 | | **Provider** | [azure](https://azure.microsoft.com/) | >= 3.116.0 | ## 示例 **重要提示:** 由于源中使用的 master 分支会根据新的修改而变化,我们建议使用 [发布版本](https://github.com/terraform-az-modules/terraform-azure-firewall/releases)。 📌 如需更多使用示例,请查看 [`examples/`](./examples) 目录下的完整列表。 ## Providers | Name | Version | |------|---------| | [azurerm](#provider\_azurerm) | >=3.116.0 | ## Modules | Name | Source | Version | |------|--------|---------| | [labels](#module\_labels) | terraform-az-modules/tags/azurerm | 1.0.2 | ## Resources | Name | Type | |------|------| | [azurerm_firewall.firewall](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/firewall) | resource | | [azurerm_firewall_policy.policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/firewall_policy) | resource | | [azurerm_firewall_policy_rule_collection_group.app_policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/firewall_policy_rule_collection_group) | resource | | [azurerm_firewall_policy_rule_collection_group.nat_policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/firewall_policy_rule_collection_group) | resource | | [azurerm_firewall_policy_rule_collection_group.network_policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/firewall_policy_rule_collection_group) | resource | | [azurerm_monitor_diagnostic_setting.firewall_diagnostic](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_diagnostic_setting) | resource | | [azurerm_public_ip.public_ip](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip) | resource | | [azurerm_public_ip_prefix.pip_prefix](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip_prefix) | resource | | [azurerm_user_assigned_identity.identity](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/user_assigned_identity) | resource | ## 输入变量 | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [app\_policy\_collection\_group](#input\_app\_policy\_collection\_group) | (可选) 应用策略组的名称 | `string` | `"DefaultApplicationRuleCollectionGroup"` | no | | [application\_rule\_collection](#input\_application\_rule\_collection) | 防火墙策略的应用程序规则集合列表。 |
list(object({
name = string
priority = number
action = string
rules = list(object({
name = string
source_addresses = optional(list(string), []) # 可选: 源 IP 地址列表
source_ip_groups = optional(list(string), []) # 可选: 源 IP 组列表
destination_fqdns = optional(list(string), []) # 可选: 目标 FQDN 列表
destination_ip_groups = optional(list(string), []) # 可选: 目标 IP 组列表
protocols = list(object({
port = optional(number, null) # 可选: 端口号
type = optional(string, null) # 可选: 协议类型 (例如:TCP, UDP)
}))
}))
}))
| `[]` | no | | [custom\_name](#input\_custom\_name) | 覆盖默认命名约定 | `string` | `null` | no | | [deployment\_mode](#input\_deployment\_mode) | 指定基础设施/资源的部署方式 | `string` | `"terraform"` | no | | [dns\_servers](#input\_dns\_servers) | Azure Firewall 使用的 DNS 服务器。使用此选项也会激活 DNS 代理。 | `list(string)` | `null` | no | | [enable\_diagnostic](#input\_enable\_diagnostic) | 设置为 false 可阻止模块为防火墙资源创建诊断设置。 | `bool` | `false` | no | | [enabled](#input\_enabled) | 设置为 false 可阻止模块创建任何资源。 | `bool` | `true` | no | | [environment](#input\_environment) | 环境 (例如 `prod`, `dev`, `staging`)。 | `string` | `""` | no | | [eventhub\_authorization\_rule\_id](#input\_eventhub\_authorization\_rule\_id) | Eventhub 授权规则 ID,用于传递给防火墙诊断设置的目标详细信息。 | `string` | `null` | no | | [eventhub\_name](#input\_eventhub\_name) | Eventhub 名称,用于传递给防火墙诊断设置的目标详细信息。 | `string` | `null` | no | | [extra\_tags](#input\_extra\_tags) | 用于传递额外标签的变量。 | `map(string)` | `null` | no | | [firewall\_enable](#input\_firewall\_enable) | 值为 true 或 false。设置为 true 以启用防火墙创建。如果设置为 false,则不会创建防火墙。 | `bool` | `false` | no | | [firewall\_policy\_id](#input\_firewall\_policy\_id) | 防火墙策略的 ID。 | `string` | `null` | no | | [firewall\_private\_ip\_ranges](#input\_firewall\_private\_ip\_ranges) | SNAT 私有 CIDR IP 范围列表,或特殊字符串 `IANAPrivateRanges`,表示当目标 IP 地址属于 IANA RFC 1918 定义的私有范围时,Azure Firewall 不进行 SNAT。 | `list(string)` | `null` | no | | [identity\_type](#input\_identity\_type) | 指定应在此存储账户上配置的托管服务标识类型。可能的值为 `SystemAssigned`、`UserAssigned`、`SystemAssigned, UserAssigned`(同时启用两者)。 | `string` | `"UserAssigned"` | no | | [label\_order](#input\_label\_order) | 资源名称中标签的顺序。默认顺序为 ['name', 'environment', 'location']。您可以根据需要将其更改为 ['environment', 'name', 'location'] 或任何其他顺序。 | `list(any)` |
[
"name",
"environment",
"location"
]
| no | | [location](#input\_location) | 创建防火墙的位置/区域。更改此设置将强制创建新资源。 | `string` | `""` | no | | [log\_analytics\_destination\_type](#input\_log\_analytics\_destination\_type) | 可能的值为 AzureDiagnostics 和 Dedicated,默认为 AzureDiagnostics。当设置为 Dedicated 时,发送到 Log Analytics 工作区的日志将进入特定资源表,而不是旧的 AzureDiagnostics 表。 | `string` | `"AzureDiagnostics"` | no | | [log\_analytics\_workspace\_id](#input\_log\_analytics\_workspace\_id) | Log Analytics 工作区 ID,用于传递给防火墙诊断设置的目标详细信息。 | `string` | `null` | no | | [logs](#input\_logs) | 要为诊断设置启用的日志列表。 |
list(object({
category_group = optional(string)
category = optional(string)
}))
| `[]` | no | | [managedby](#input\_managedby) | 管理者,例如 'terraform-az-modules'。 | `string` | `"terraform-az-modules"` | no | | [metric\_enabled](#input\_metric\_enabled) | 设置为 true 以启用诊断设置的指标。 | `bool` | `false` | no | | [name](#input\_name) | 名称 (例如 `app` 或 `cluster`)。 | `string` | `""` | no | | [nat\_policy\_collection\_group](#input\_nat\_policy\_collection\_group) | (可选) NAT 策略组的名称 | `string` | `"DefaultDnatRuleCollectionGroup"` | no | | [nat\_rule\_collection](#input\_nat\_rule\_collection) | 防火墙策略的 NAT 规则集合列表。 |
list(object({
name = string
priority = number
description = optional(string, null) # 可选: NAT 规则集合的描述
rules = list(object({
name = string
protocols = list(string) # 协议列表 (例如:TCP, UDP)
source_addresses = optional(list(string), []) # 可选: 源 IP 地址列表
destination_address = optional(string, null) # 可选: 目标 IP 地址列表
destination_ports = optional(list(string), []) # 可选: 目标端口列表
translated_address = string # 必需: 流量转发到的内部 IP
translated_port = optional(string, null) # 可选: 流量转发到的内部端口
source_ip_groups = optional(list(string), []) # 可选: 源 IP 组列表
destination_ip_groups = optional(list(string), []) # 可选: 目标 IP 组列表
}))
}))
| `[]` | no | | [net\_policy\_collection\_group](#input\_net\_policy\_collection\_group) | (可选) 网络策略组的名称 | `string` | `"DefaultNetworkRuleCollectionGroup"` | no | | [network\_rule\_collection](#input\_network\_rule\_collection) | 防火墙策略的网络规则集合列表。 |
list(object({
name = string
priority = number
action = string
description = optional(string, null) # 可选: 规则集合的描述
rules = list(object({
name = string
protocols = list(string) # 协议列表 (例如:TCP, UDP, ICMP)
source_addresses = optional(list(string), []) # 可选: 源 IP 地址列表
source_ip_groups = optional(list(string), []) # 可选: 源 IP 组列表
destination_addresses = optional(list(string), []) # 可选: 目标 IP 地址列表
destination_ip_groups = optional(list(string), []) # 可选: 目标 IP 组列表
destination_ports = optional(list(string), []) # 可选: 目标端口列表
destination_fqdns = optional(list(string), []) # 可选: 目标 FQDN 列表
}))
}))
| `[]` | no | | [policy\_rule\_enabled](#input\_policy\_rule\_enabled) | 用于控制策略规则创建的标志。 | `bool` | `false` | | | [public\_ip\_allocation\_method](#input\_public\_ip\_allocation\_method) | 定义此 IP 地址的分配方法。可能的值为 Static 或 Dynamic | `string` | `"Static"` | no | | [public\_ip\_names](#input\_public\_ip\_names) | 要创建的公共 IP 名称列表。 | `list(string)` | `[]` | no | | [public\_ip\_prefix\_enable](#input\_public\_ip\_prefix\_enable) | 用于控制公共 IP 前缀资源创建的标志。 | `bool` | `false` | no | | [public\_ip\_prefix\_ip\_version](#input\_public\_ip\_prefix\_ip\_version) | 要使用的 IP 版本,IPv6 或 IPv4。更改此设置将强制创建新资源。默认值为 IPv4 | `string` | `"IPv4"` | no | | [public\_ip\_prefix\_length](#input\_public\_ip\_prefix\_length) | 指定前缀的位数。该值可设置在 0 (4,294,967,296 个地址) 到 31 (2 个地址) 之间。默认值为 28(16 个地址)。更改此设置将强制创建新资源。 | `number` | `28` | no | | [public\_ip\_prefix\_sku](#input\_public\_ip\_prefix\_sku) | 公共 IP 前缀的 SKU。默认为 Standard。 | `string` | `"Standard"` | no | | [public\_ip\_sku](#input\_public\_ip\_sku) | 公共 IP 的 SKU。接受的值为 Basic 和 Standard。默认为 Standard | `string` | `"Standard"` | no | | [repository](#input\_repository) | Terraform 当前模块的代码库 | `string` | `"https://github.com/terraform-az-modules/terraform-azure-firewall"` | no | | [resource\_group\_name](#input\_resource\_group\_name) | 用于保存 Azure 解决方案相关资源的容器 | `string` | `""` | no | | [resource\_position\_prefix](#input\_resource\_position\_prefix) | 控制资源类型关键字(例如 "vnet", "ddospp")在资源名称中的位置。

- 如果为 true,关键字将被置于前缀位置:"vnet-core-dev"。
- 如果为 false,关键字将被置于后缀位置:"core-dev-vnet"。

这有助于根据组织偏好保持命名一致性。 | `bool` | `true` | no | | [sku\_name](#input\_sku\_name) | 防火墙的 SKU 名称。可能的值为 `AZFW_VNet` 和 `AZFW_Hub`。 | `string` | `"AZFW_VNet"` | no | | [sku\_policy](#input\_sku\_policy) | 指定防火墙策略的 SKU | `string` | `"Standard"` | no | | [sku\_tier](#input\_sku\_tier) | 指定防火墙 SKU 层级 | `string` | `"Standard"` | no | | [storage\_account\_id](#input\_storage\_account\_id) | 存储账户 ID,用于传递给防火墙诊断设置的目标详细信息。 | `string` | `null` | no | | [subnet\_id](#input\_subnet\_id) | 要将防火墙附加到的子网的 ID。如果未指定,模块将在指定的虚拟网络中创建一个名为 'AzureFirewallSubnet' 的新子网。 | `string` | `""` | no | | [threat\_intel\_mode](#input\_threat\_intel\_mode) | (可选) 基于威胁情报的过滤的操作模式。可能的值为:Off, Alert, Deny。默认为 Alert。 | `string` | `"Alert"` | no | ## 输出 | Name | Description | |------|-------------| | [firewall\_id](#output\_firewall\_id) | 防火墙 ID | | [firewall\_name](#output\_firewall\_name) | 防火墙名称 | | [firewall\_policy\_id](#output\_firewall\_policy\_id) | 防火墙策略 ID 的值 | | [public\_ip\_addresses](#output\_public\_ip\_addresses) | 公共 IP 地址的值 | | [public\_ip\_ids](#output\_public\_ip\_ids) | 所有公共 IP 的 ID | | [public\_ip\_prefix\_id](#output\_public\_ip\_prefix\_id) | 公共 IP 前缀 ID 的值 | ## 模块依赖 此模块依赖于: - [标签模块](https://github.com/terraform-az-modules/terraform-azure-tags):提供资源标记功能。 ## 📑 更新日志 请参阅[此处](CHANGELOG.md)。 ## 反馈 发现了错误或有想法要与我们分享?让我们一起来解决它!请在我们的[问题跟踪器](https://github.com/terraform-az-modules/terraform-azure-module-template/issues)中记录,或随时发送电子邮件至 [hello@clouddrove.com](hello@clouddrove.com)。 ## :rocket: 我们的成就 我们拥有 [*50 多个 Azure Terraform 模块*][terraform_modules] 🙌。您可以认为它们已经完成,但有了像您这样的爱好者,我们能够不断改进它们,因此我们将我们的状态称为 —— 持续改进中。 - [Terraform 模块注册表:](https://registry.terraform.io/namespaces/clouddrove) 在这里发现我们的 Terraform 模块。
标签:Azure, Azure Firewall, EC2, ECS, IaC, Microsoft Azure, Terraform, 威胁防护, 模块, 流量过滤, 特权提升, 网络安全, 网络隔离, 自动化部署, 资源管理, 防火墙, 隐私保护