Skip to content
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

Feat: Add option for tags and descriptions #1

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
# terraform-azure-mcaf-vwan

<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.7 |
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 4 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | 4.7.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_vhub"></a> [vhub](#module\_vhub) | ./modules/vhub | n/a |

## Resources

| Name | Type |
|------|------|
| [azurerm_resource_group.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
| [azurerm_virtual_wan.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_wan) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_resource_group"></a> [resource\_group](#input\_resource\_group) | n/a | <pre>object({<br> name = string<br> location = string<br> })</pre> | n/a | yes |
| <a name="input_virtual_hubs"></a> [virtual\_hubs](#input\_virtual\_hubs) | n/a | <pre>map(object({<br> virtual_hub_name = string<br> location = string<br> address_prefix = string<br> routing_intent_name = string<br> firewall_name = string<br> firewall_policy_name = string<br> firewall_sku_tier = string<br> firewall_public_ip_count = number<br> firewall_threat_intelligence_mode = string<br> firewall_proxy_enabled = bool<br> firewall_dns_servers = list(string)<br> }))</pre> | n/a | yes |
| <a name="input_virtual_wan"></a> [virtual\_wan](#input\_virtual\_wan) | n/a | <pre>object({<br> name = string<br> location = string<br> })</pre> | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | n/a | `map(string)` | `{}` | no |

## Outputs

No outputs.
<!-- END_TF_DOCS -->
2 changes: 2 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This Terraform configuration defines resources and a module for deploying an Azure Virtual WAN setup.

resource "azurerm_resource_group" "this" {
name = var.resource_group.name
location = var.resource_group.location
Expand Down
27 changes: 27 additions & 0 deletions modules/vhub/main.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@

# This Terraform configuration defines resources for an Azure Virtual Hub setup, including:
# - azurerm_virtual_hub: Represents a Virtual Hub in Azure Virtual WAN.
# - azurerm_virtual_hub_routing_intent: Defines routing policies for the Virtual Hub.
# - azurerm_firewall: Configures an Azure Firewall associated with the Virtual Hub.
# - azurerm_firewall_policy: Specifies the Firewall Policy for the Azure Firewall.


resource "azurerm_virtual_hub" "this" {
name = var.virtual_hubs.virtual_hub_name
resource_group_name = var.resource_group_name
location = var.virtual_hubs.location
address_prefix = var.virtual_hubs.address_prefix
virtual_wan_id = var.virtual_wan_id
tags = merge(
try(var.tags),
tomap({
"Resource Type" = "Resource Group"
})
)
}



resource "azurerm_virtual_hub_routing_intent" "this" {
name = var.virtual_hubs.routing_intent_name
virtual_hub_id = azurerm_virtual_hub.this.id
Expand Down Expand Up @@ -34,6 +49,12 @@ resource "azurerm_firewall" "this" {
virtual_hub_id = azurerm_virtual_hub.this.id
public_ip_count = var.virtual_hubs.firewall_public_ip_count
}
tags = merge(
try(var.tags),
tomap({
"Resource Type" = "Firewall"
})
)
}

resource "azurerm_firewall_policy" "this" {
Expand All @@ -46,5 +67,11 @@ resource "azurerm_firewall_policy" "this" {
proxy_enabled = var.virtual_hubs.firewall_proxy_enabled
servers = var.virtual_hubs.firewall_dns_servers
}
tags = merge(
try(var.tags),
tomap({
"Resource Type" = "Firewall Policy"
})
)
}

53 changes: 43 additions & 10 deletions modules/vhub/variables.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,49 @@
# variable "virtual_hubs"
# This variable defines the configuration for virtual hubs.
# - virtual_hub_name: The name of the virtual hub (string).
# - location: The location/region of the virtual hub (string).
# - address_prefix: The address prefix for the virtual hub (string).
# - routing_intent_name: The name of the routing intent (string).
# - firewall_name: The name of the firewall (string).
# - firewall_policy_name: The name of the firewall policy (string).
# - firewall_sku_tier: The SKU tier of the firewall (string).
# - firewall_public_ip_count: The number of public IPs for the firewall (number).
# - firewall_threat_intelligence_mode: The threat intelligence mode for the firewall (string).
# - firewall_proxy_enabled: Whether the firewall proxy is enabled (bool).
# - firewall_dns_servers: A list of DNS servers for the firewall (list of strings).

# variable "tags"
# This variable defines a map of tags to be applied to resources.
# - type: A map of strings.
# - default: An empty map by default.

# variable "virtual_wan_id"
# This variable defines the ID of the virtual WAN.
# - type: string.

# variable "resource_group_name"
# This variable defines the name of the resource group.
# - type: string.

variable "tags" {
type = map(string)
default = {}
}


variable "virtual_hubs" {
type = object({
virtual_hub_name = string
location = string
address_prefix = string
routing_intent_name = string
firewall_name = string
firewall_policy_name = string
firewall_sku_tier = string
firewall_public_ip_count = number
location = string
address_prefix = string
routing_intent_name = string
firewall_name = string
firewall_policy_name = string
firewall_sku_tier = string
firewall_public_ip_count = number
firewall_threat_intelligence_mode = string
firewall_proxy_enabled = bool
firewall_dns_servers = list(string)
firewall_proxy_enabled = bool
firewall_dns_servers = list(string)

})
}
Expand All @@ -21,4 +54,4 @@ variable "virtual_wan_id" {

variable "resource_group_name" {
type = string
}
}
2 changes: 1 addition & 1 deletion terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ terraform {
version = ">= 4"
}
}
}
}
49 changes: 39 additions & 10 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# variable "virtual_hubs"
# This variable defines the configuration for virtual hubs.
# - virtual_hub_name: The name of the virtual hub (string).
# - location: The location/region of the virtual hub (string).
# - address_prefix: The address prefix for the virtual hub (string).
# - routing_intent_name: The name of the routing intent (string).
# - firewall_name: The name of the firewall (string).
# - firewall_policy_name: The name of the firewall policy (string).
# - firewall_sku_tier: The SKU tier of the firewall (string).
# - firewall_public_ip_count: The number of public IPs for the firewall (number).
# - firewall_threat_intelligence_mode: The threat intelligence mode for the firewall (string).
# - firewall_proxy_enabled: Whether the firewall proxy is enabled (bool).
# - firewall_dns_servers: A list of DNS servers for the firewall (list of strings).

# variable "tags"
# This variable defines a map of tags to be applied to resources.
# - type: A map of strings.
# - default: An empty map by default.


# variable "resource_group_name"
# This variable defines the name of the resource group.
# - type: string.

variable "tags" {
type = map(string)
default = {}
}

variable "resource_group" {
type = object({
name = string
Expand All @@ -14,16 +43,16 @@ variable "virtual_wan" {

variable "virtual_hubs" {
type = map(object({
virtual_hub_name = string
location = string
address_prefix = string
routing_intent_name = string
firewall_name = string
firewall_policy_name = string
firewall_sku_tier = string
firewall_public_ip_count = number
virtual_hub_name = string
location = string
address_prefix = string
routing_intent_name = string
firewall_name = string
firewall_policy_name = string
firewall_sku_tier = string
firewall_public_ip_count = number
firewall_threat_intelligence_mode = string
firewall_proxy_enabled = bool
firewall_dns_servers = list(string)
firewall_proxy_enabled = bool
firewall_dns_servers = list(string)
}))
}