Skip to content

Commit c42e900

Browse files
committed
fix: fixing tests
1 parent c4238cb commit c42e900

File tree

5 files changed

+35
-20
lines changed

5 files changed

+35
-20
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ aws s3 ls --endpoint-url https://your-domain.region.azurecontainer.io:8443 --no-
169169
| Name | Version |
170170
|------|---------|
171171
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | 4.36.0 |
172+
| <a name="requirement_random"></a> [random](#requirement\_random) | ~> 3.1 |
172173

173174
## Modules
174175

@@ -183,24 +184,25 @@ No modules.
183184
| [azurerm_resource_group.minio_aci_rg](https://registry.terraform.io/providers/hashicorp/azurerm/4.36.0/docs/resources/resource_group) | resource |
184185
| [azurerm_storage_account.minio_storage_account](https://registry.terraform.io/providers/hashicorp/azurerm/4.36.0/docs/resources/storage_account) | resource |
185186
| [azurerm_storage_share.minio_storage_share](https://registry.terraform.io/providers/hashicorp/azurerm/4.36.0/docs/resources/storage_share) | resource |
187+
| [random_string.storage_suffix](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
186188

187189
## Inputs
188190

189191
| Name | Description | Type | Default | Required |
190192
|------|-------------|------|---------|:--------:|
191193
| <a name="input_cert_password"></a> [cert\_password](#input\_cert\_password) | Password for the SSL certificate | `string` | n/a | yes |
192194
| <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 |
193-
| <a name="input_location"></a> [location](#input\_location) | Azure region for deployment | `string` | n/a | yes |
195+
| <a name="input_location"></a> [location](#input\_location) | Azure region for deployment | `string` | `"West Europe"` | no |
194196
| <a name="input_minio_image"></a> [minio\_image](#input\_minio\_image) | MinIO container image | `string` | `"quay.io/minio/minio:RELEASE.2025-09-07T16-13-09Z"` | no |
195197
| <a name="input_minio_root_password"></a> [minio\_root\_password](#input\_minio\_root\_password) | MinIO root password for admin access | `string` | n/a | yes |
196-
| <a name="input_minio_root_user"></a> [minio\_root\_user](#input\_minio\_root\_user) | MinIO root username for admin access | `string` | n/a | yes |
198+
| <a name="input_minio_root_user"></a> [minio\_root\_user](#input\_minio\_root\_user) | MinIO root username for admin access | `string` | `"minioadmin"` | no |
197199
| <a name="input_nginx_image"></a> [nginx\_image](#input\_nginx\_image) | Nginx container image | `string` | `"mcr.microsoft.com/azurelinux/base/nginx:1.25"` | no |
198200
| <a name="input_public_url_domain_name"></a> [public\_url\_domain\_name](#input\_public\_url\_domain\_name) | Domain name for the public URL (e.g., 'miniotest' creates 'miniotest.westeurope.azurecontainer.io') | `string` | n/a | yes |
199201
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | Name of the Resource Group where you want to deploy MinIO | `string` | n/a | yes |
200202
| <a name="input_ssl_cert_file"></a> [ssl\_cert\_file](#input\_ssl\_cert\_file) | Name of the SSL certificate file | `string` | `"server.crt"` | no |
201203
| <a name="input_ssl_key_file"></a> [ssl\_key\_file](#input\_ssl\_key\_file) | Name of the SSL private key file | `string` | `"server.key"` | no |
202-
| <a name="input_storage_account_name"></a> [storage\_account\_name](#input\_storage\_account\_name) | Storage Account Name (must be globally unique across Azure) | `string` | n/a | yes |
203-
| <a name="input_storage_share_size"></a> [storage\_share\_size](#input\_storage\_share\_size) | Storage space needed in GBs (minimum 1GB, maximum 5120GB/5TB) | `number` | n/a | yes |
204+
| <a name="input_storage_account_name"></a> [storage\_account\_name](#input\_storage\_account\_name) | Storage Account Name prefix (random suffix will be added for global uniqueness) | `string` | `"miniostorage"` | no |
205+
| <a name="input_storage_share_size"></a> [storage\_share\_size](#input\_storage\_share\_size) | Storage space needed in GBs (minimum 1GB, maximum 5120GB/5TB) | `number` | `100` | no |
204206

205207
## Outputs
206208

main.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
resource "random_string" "storage_suffix" {
2+
length = 4
3+
special = false
4+
upper = false
5+
}
6+
17
resource "azurerm_resource_group" "minio_aci_rg" {
28
name = var.resource_group_name
39
location = var.location
@@ -201,7 +207,7 @@ resource "azurerm_log_analytics_workspace" "minio_law" {
201207
}
202208

203209
resource "azurerm_storage_account" "minio_storage_account" {
204-
name = var.storage_account_name
210+
name = "${var.storage_account_name}${random_string.storage_suffix.result}"
205211
resource_group_name = azurerm_resource_group.minio_aci_rg.name
206212
location = var.location
207213
account_tier = "Standard"

terraform.tftest.hcl

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ run "complete_minio_deployment" {
1010
ssl_key_file = "server-tftest.key"
1111
cert_password = "CertPassword123!"
1212
storage_share_size = 100
13-
storage_account_name = "testminiostorage001"
13+
storage_account_name = "testminio" # prefix only
1414
public_url_domain_name = "testminio"
1515
}
1616

@@ -62,12 +62,7 @@ run "complete_minio_deployment" {
6262
error_message = "Container group should expose MinIO API port 8443"
6363
}
6464

65-
# Test storage configuration
66-
assert {
67-
condition = azurerm_storage_account.minio_storage_account.name == var.storage_account_name
68-
error_message = "Storage account should use the specified name"
69-
}
70-
65+
# Test storage configuration (prefix + random suffix handled in resource)
7166
assert {
7267
condition = azurerm_storage_share.minio_storage_share.quota == var.storage_share_size
7368
error_message = "Storage share should use the specified size"
@@ -111,7 +106,7 @@ run "nginx_ssl_configuration" {
111106
ssl_key_file = "server-tftest.key"
112107
cert_password = "CertPassword123!"
113108
storage_share_size = 100
114-
storage_account_name = "testminiostorage002"
109+
storage_account_name = "testminio002"
115110
public_url_domain_name = "testminio"
116111
}
117112

@@ -152,7 +147,7 @@ run "storage_size_validation" {
152147
ssl_key_file = "server-tftest.key"
153148
cert_password = "CertPassword123!"
154149
storage_share_size = 1000
155-
storage_account_name = "testminiostorage003"
150+
storage_account_name = "testminio003"
156151
public_url_domain_name = "testminio"
157152
}
158153

@@ -177,7 +172,7 @@ run "invalid_storage_size" {
177172
ssl_key_file = "server-tftest.key"
178173
cert_password = "CertPassword123!"
179174
storage_share_size = 0
180-
storage_account_name = "testminiostorage004"
175+
storage_account_name = "testminio004"
181176
public_url_domain_name = "testminio"
182177
}
183178
}
@@ -197,7 +192,7 @@ run "invalid_storage_size_too_large" {
197192
ssl_key_file = "server-tftest.key"
198193
cert_password = "CertPassword123!"
199194
storage_share_size = 6000
200-
storage_account_name = "testminiostorage005"
195+
storage_account_name = "testminio005"
201196
public_url_domain_name = "testminio"
202197
}
203198
}
@@ -216,7 +211,7 @@ run "empty_credentials" {
216211
minio_root_password = ""
217212
cert_password = "CertPassword123!"
218213
storage_share_size = 100
219-
storage_account_name = "testminiostorage006"
214+
storage_account_name = "testminio006"
220215
public_url_domain_name = "testminio"
221216
}
222217
}
@@ -236,7 +231,7 @@ run "missing_certificate" {
236231
ssl_key_file = "server-tftest.key"
237232
cert_password = ""
238233
storage_share_size = 100
239-
storage_account_name = "testminiostorage007"
234+
storage_account_name = "testminio007"
240235
public_url_domain_name = "testminio"
241236
}
242237
}

variables.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ variable "resource_group_name" {
44
}
55

66
variable "location" {
7+
default = "West Europe"
78
type = string
89
description = "Azure region for deployment"
910
}
1011

1112
variable "minio_root_user" {
13+
default = "minioadmin"
1214
type = string
1315
nullable = false
1416
description = "MinIO root username for admin access"
@@ -41,6 +43,7 @@ variable "cert_password" {
4143
}
4244

4345
variable "storage_share_size" {
46+
default = 100
4447
type = number
4548
description = "Storage space needed in GBs (minimum 1GB, maximum 5120GB/5TB)"
4649
validation {
@@ -51,9 +54,15 @@ variable "storage_share_size" {
5154

5255
variable "storage_account_name" {
5356
type = string
54-
description = "Storage Account Name (must be globally unique across Azure)"
57+
default = "miniostorage"
58+
description = "Storage Account Name prefix (random suffix will be added for global uniqueness)"
59+
validation {
60+
condition = can(regex("^[a-z0-9]{3,24}$", var.storage_account_name))
61+
error_message = "Storage account name prefix must be 3-24 characters, lowercase letters and numbers only. No special characters or uppercase letters allowed."
62+
}
5563
}
5664

65+
5766
variable "public_url_domain_name" {
5867
type = string
5968
description = "Domain name for the public URL (e.g., 'miniotest' creates 'miniotest.westeurope.azurecontainer.io')"

versions.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ terraform {
44
source = "hashicorp/azurerm"
55
version = "4.36.0"
66
}
7+
random = {
8+
source = "hashicorp/random"
9+
version = "~> 3.1"
10+
}
711
}
812
}
9-

0 commit comments

Comments
 (0)