Skip to content

Commit aa1ca73

Browse files
authored
Merge pull request #7 from meshcloud/feature/ip-address-string
Feature/ip address string
2 parents e289fbb + bdd57bf commit aa1ca73

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ No modules.
163163
| [azurerm_container_group.minio_aci_container_group](https://registry.terraform.io/providers/hashicorp/azurerm/4.36.0/docs/resources/container_group) | resource |
164164
| [azurerm_key_vault.minio_kv](https://registry.terraform.io/providers/hashicorp/azurerm/4.36.0/docs/resources/key_vault) | resource |
165165
| [azurerm_key_vault_access_policy.agw_policy](https://registry.terraform.io/providers/hashicorp/azurerm/4.36.0/docs/resources/key_vault_access_policy) | resource |
166-
| [azurerm_key_vault_access_policy.tf](https://registry.terraform.io/providers/hashicorp/azurerm/4.36.0/docs/resources/key_vault_access_policy) | resource |
166+
| [azurerm_key_vault_access_policy.minio_cert_policy](https://registry.terraform.io/providers/hashicorp/azurerm/4.36.0/docs/resources/key_vault_access_policy) | resource |
167167
| [azurerm_key_vault_certificate.minio_cert](https://registry.terraform.io/providers/hashicorp/azurerm/4.36.0/docs/resources/key_vault_certificate) | resource |
168168
| [azurerm_log_analytics_workspace.minio_law](https://registry.terraform.io/providers/hashicorp/azurerm/4.36.0/docs/resources/log_analytics_workspace) | resource |
169169
| [azurerm_network_security_group.agw_nsg](https://registry.terraform.io/providers/hashicorp/azurerm/4.36.0/docs/resources/network_security_group) | resource |
@@ -188,7 +188,7 @@ No modules.
188188

189189
| Name | Description | Type | Default | Required |
190190
|------|-------------|------|---------|:--------:|
191-
| <a name="input_allowed_ip_addresses"></a> [allowed\_ip\_addresses](#input\_allowed\_ip\_addresses) | List of IP addresses that will be allowed to access the MinIO service (CIDR format, e.g., ['203.0.113.0/32', '192.168.1.0/24']) | `list(string)` | n/a | yes |
191+
| <a name="input_allowed_ip_addresses"></a> [allowed\_ip\_addresses](#input\_allowed\_ip\_addresses) | Comma-separated list of IP addresses that will be allowed to access the MinIO service in CIDR format. Example: '203.0.113.0/32' for a single IP or '10.10.10.2/32,192.168.1.0/24' for multiple IPs. | `string` | `"10.10.10.2/32"` | no |
192192
| <a name="input_coraza_waf_image"></a> [coraza\_waf\_image](#input\_coraza\_waf\_image) | Coraza WAF container image | `string` | `"ghcr.io/meshcloud/minio_azure_container_app/coraza-caddy:caddy-2.8-coraza-v2.0.0"` | no |
193193
| <a name="input_location"></a> [location](#input\_location) | Azure region for deployment | `string` | `"West Europe"` | no |
194194
| <a name="input_minio_image"></a> [minio\_image](#input\_minio\_image) | MinIO container image | `string` | `"quay.io/minio/minio:RELEASE.2025-04-22T22-12-26Z"` | no |

main.tf

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ resource "azurerm_key_vault" "minio_kv" {
8383
soft_delete_retention_days = 7
8484
}
8585

86-
resource "azurerm_key_vault_access_policy" "tf" {
86+
resource "azurerm_key_vault_access_policy" "minio_cert_policy" {
8787
key_vault_id = azurerm_key_vault.minio_kv.id
8888
tenant_id = data.azurerm_client_config.current.tenant_id
8989
object_id = data.azurerm_client_config.current.object_id
@@ -116,6 +116,7 @@ resource "azurerm_key_vault_certificate" "minio_cert" {
116116

117117
}
118118
}
119+
depends_on = [azurerm_key_vault_access_policy.minio_cert_policy]
119120
}
120121

121122
resource "azurerm_user_assigned_identity" "agw_identity" {
@@ -147,31 +148,37 @@ resource "azurerm_network_security_group" "agw_nsg" {
147148
resource_group_name = azurerm_resource_group.minio_rg.name
148149
}
149150

151+
locals {
152+
allowed_ips_list = [
153+
for ip in split(",", var.allowed_ip_addresses) : trimspace(ip)
154+
]
155+
}
156+
150157
resource "azurerm_network_security_rule" "allow_https_ui" {
151-
count = length(var.allowed_ip_addresses)
158+
count = length(local.allowed_ips_list)
152159
name = "AllowHTTPS-UI-${count.index}"
153160
priority = 100 + count.index
154161
direction = "Inbound"
155162
access = "Allow"
156163
protocol = "Tcp"
157164
source_port_range = "*"
158165
destination_port_range = "443"
159-
source_address_prefix = var.allowed_ip_addresses[count.index]
166+
source_address_prefix = local.allowed_ips_list[count.index]
160167
destination_address_prefix = "*"
161168
resource_group_name = azurerm_resource_group.minio_rg.name
162169
network_security_group_name = azurerm_network_security_group.agw_nsg.name
163170
}
164171

165172
resource "azurerm_network_security_rule" "allow_https_api" {
166-
count = length(var.allowed_ip_addresses)
173+
count = length(local.allowed_ips_list)
167174
name = "AllowHTTPS-API-${count.index}"
168175
priority = 200 + count.index
169176
direction = "Inbound"
170177
access = "Allow"
171178
protocol = "Tcp"
172179
source_port_range = "*"
173180
destination_port_range = "8443"
174-
source_address_prefix = var.allowed_ip_addresses[count.index]
181+
source_address_prefix = local.allowed_ips_list[count.index]
175182
destination_address_prefix = "*"
176183
resource_group_name = azurerm_resource_group.minio_rg.name
177184
network_security_group_name = azurerm_network_security_group.agw_nsg.name

variables.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ variable "coraza_waf_image" {
7676
}
7777

7878
variable "allowed_ip_addresses" {
79-
type = list(string)
80-
description = "List of IP addresses that will be allowed to access the MinIO service (CIDR format, e.g., ['203.0.113.0/32', '192.168.1.0/24'])"
79+
type = string
80+
description = "Comma-separated list of IP addresses that will be allowed to access the MinIO service in CIDR format. Example: '203.0.113.0/32' for a single IP or '10.10.10.2/32,192.168.1.0/24' for multiple IPs."
81+
default = "10.10.10.2/32"
8182
validation {
8283
condition = alltrue([
83-
for ip in var.allowed_ip_addresses : can(cidrhost(ip, 0))
84+
for ip in split(",", var.allowed_ip_addresses) : can(cidrhost(trimspace(ip), 0))
8485
])
85-
error_message = "All IP addresses must be in valid CIDR format (e.g., '203.0.113.0/32' for a single IP or '192.168.1.0/24' for a subnet)."
86+
error_message = "All IP addresses must be in valid CIDR format (e.g., '10.10.10.2/32' for a single IP or '192.168.1.0/24' for a subnet)."
8687
}
8788
}

0 commit comments

Comments
 (0)