Skip to content

Commit 8067fd4

Browse files
committed
Split example TF configs into standard module structure
Move variables and outputs from main.tf into separate variables.tf and outputs.tf for all three examples (ai-startup, saas-startup, api-first-startup) to satisfy tflint terraform_standard_module_structure rule and fix CI validation failures.
1 parent 785bd6a commit 8067fd4

File tree

9 files changed

+373
-379
lines changed

9 files changed

+373
-379
lines changed

examples/ai-startup/terraform/main.tf

Lines changed: 0 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -27,104 +27,6 @@ provider "azurerm" {
2727
subscription_id = var.subscription_id
2828
}
2929

30-
# ==============================================================================
31-
# Variables
32-
# ==============================================================================
33-
34-
variable "subscription_id" {
35-
description = "Azure subscription ID"
36-
type = string
37-
validation {
38-
condition = can(regex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", var.subscription_id))
39-
error_message = "subscription_id must be a valid UUID."
40-
}
41-
}
42-
43-
variable "resource_group_name" {
44-
description = "Resource group to deploy into"
45-
type = string
46-
}
47-
48-
variable "location" {
49-
description = "Azure region"
50-
type = string
51-
default = "eastus2"
52-
}
53-
54-
variable "app_name" {
55-
description = "Application name prefix (lowercase alphanumeric, max 12 chars to fit resource naming limits)"
56-
type = string
57-
validation {
58-
condition = can(regex("^[a-z][a-z0-9]{1,11}$", var.app_name))
59-
error_message = "app_name must be 2-12 lowercase alphanumeric characters, starting with a letter."
60-
}
61-
}
62-
63-
variable "environment" {
64-
description = "Environment: prod or nonprod"
65-
type = string
66-
default = "prod"
67-
validation {
68-
condition = contains(["prod", "nonprod"], var.environment)
69-
error_message = "Environment must be 'prod' or 'nonprod'."
70-
}
71-
}
72-
73-
variable "system_node_vm_size" {
74-
description = "AKS system node VM size"
75-
type = string
76-
default = "Standard_D4s_v5"
77-
}
78-
79-
variable "gpu_node_vm_size" {
80-
description = "GPU node VM size"
81-
type = string
82-
default = "Standard_NC6s_v3"
83-
}
84-
85-
variable "cpu_node_vm_size" {
86-
description = "CPU burst node pool VM size"
87-
type = string
88-
default = "Standard_D4s_v5"
89-
}
90-
91-
variable "gpu_use_spot" {
92-
description = "Use Spot VMs for GPU node pool"
93-
type = bool
94-
default = true
95-
}
96-
97-
variable "kubernetes_version" {
98-
description = "AKS Kubernetes version"
99-
type = string
100-
default = "1.30"
101-
}
102-
103-
variable "ssh_public_key" {
104-
description = "SSH public key for AKS nodes"
105-
type = string
106-
}
107-
108-
variable "aks_admin_username" {
109-
description = "Linux admin username for AKS nodes"
110-
type = string
111-
default = "azureuser"
112-
}
113-
114-
variable "tags" {
115-
description = "Tags applied to all resources"
116-
type = map(string)
117-
default = {}
118-
}
119-
120-
locals {
121-
tags = merge({
122-
environment = var.environment
123-
team = "ml-engineering"
124-
project = var.app_name
125-
}, var.tags)
126-
}
127-
12830
# ==============================================================================
12931
# Data source for existing resource group
13032
# ==============================================================================
@@ -379,42 +281,3 @@ resource "azurerm_key_vault" "this" {
379281
bypass = "AzureServices"
380282
}
381283
}
382-
383-
# ==============================================================================
384-
# Outputs
385-
# ==============================================================================
386-
387-
output "aks_cluster_name" {
388-
description = "AKS cluster name (use with az aks get-credentials)"
389-
value = azurerm_kubernetes_cluster.this.name
390-
}
391-
392-
output "aks_cluster_fqdn" {
393-
description = "AKS cluster FQDN for API server access"
394-
value = azurerm_kubernetes_cluster.this.fqdn
395-
}
396-
397-
output "acr_login_server" {
398-
description = "Container registry login server (use with docker push)"
399-
value = azurerm_container_registry.this.login_server
400-
}
401-
402-
output "openai_endpoint" {
403-
description = "Azure OpenAI service endpoint URL"
404-
value = azurerm_cognitive_account.openai.endpoint
405-
}
406-
407-
output "storage_account_name" {
408-
description = "Storage account name for model artifacts and datasets"
409-
value = azurerm_storage_account.this.name
410-
}
411-
412-
output "redis_hostname" {
413-
description = "Redis cache hostname for inference caching"
414-
value = azurerm_redis_cache.this.hostname
415-
}
416-
417-
output "key_vault_uri" {
418-
description = "Key Vault URI for secret access"
419-
value = azurerm_key_vault.this.vault_uri
420-
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# ==============================================================================
2+
# Outputs
3+
# ==============================================================================
4+
5+
output "aks_cluster_name" {
6+
description = "AKS cluster name (use with az aks get-credentials)"
7+
value = azurerm_kubernetes_cluster.this.name
8+
}
9+
10+
output "aks_cluster_fqdn" {
11+
description = "AKS cluster FQDN for API server access"
12+
value = azurerm_kubernetes_cluster.this.fqdn
13+
}
14+
15+
output "acr_login_server" {
16+
description = "Container registry login server (use with docker push)"
17+
value = azurerm_container_registry.this.login_server
18+
}
19+
20+
output "openai_endpoint" {
21+
description = "Azure OpenAI service endpoint URL"
22+
value = azurerm_cognitive_account.openai.endpoint
23+
}
24+
25+
output "storage_account_name" {
26+
description = "Storage account name for model artifacts and datasets"
27+
value = azurerm_storage_account.this.name
28+
}
29+
30+
output "redis_hostname" {
31+
description = "Redis cache hostname for inference caching"
32+
value = azurerm_redis_cache.this.hostname
33+
}
34+
35+
output "key_vault_uri" {
36+
description = "Key Vault URI for secret access"
37+
value = azurerm_key_vault.this.vault_uri
38+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# ==============================================================================
2+
# Variables
3+
# ==============================================================================
4+
5+
variable "subscription_id" {
6+
description = "Azure subscription ID"
7+
type = string
8+
validation {
9+
condition = can(regex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", var.subscription_id))
10+
error_message = "subscription_id must be a valid UUID."
11+
}
12+
}
13+
14+
variable "resource_group_name" {
15+
description = "Resource group to deploy into"
16+
type = string
17+
}
18+
19+
variable "location" {
20+
description = "Azure region"
21+
type = string
22+
default = "eastus2"
23+
}
24+
25+
variable "app_name" {
26+
description = "Application name prefix (lowercase alphanumeric, max 12 chars to fit resource naming limits)"
27+
type = string
28+
validation {
29+
condition = can(regex("^[a-z][a-z0-9]{1,11}$", var.app_name))
30+
error_message = "app_name must be 2-12 lowercase alphanumeric characters, starting with a letter."
31+
}
32+
}
33+
34+
variable "environment" {
35+
description = "Environment: prod or nonprod"
36+
type = string
37+
default = "prod"
38+
validation {
39+
condition = contains(["prod", "nonprod"], var.environment)
40+
error_message = "Environment must be 'prod' or 'nonprod'."
41+
}
42+
}
43+
44+
variable "system_node_vm_size" {
45+
description = "AKS system node VM size"
46+
type = string
47+
default = "Standard_D4s_v5"
48+
}
49+
50+
variable "gpu_node_vm_size" {
51+
description = "GPU node VM size"
52+
type = string
53+
default = "Standard_NC6s_v3"
54+
}
55+
56+
variable "cpu_node_vm_size" {
57+
description = "CPU burst node pool VM size"
58+
type = string
59+
default = "Standard_D4s_v5"
60+
}
61+
62+
variable "gpu_use_spot" {
63+
description = "Use Spot VMs for GPU node pool"
64+
type = bool
65+
default = true
66+
}
67+
68+
variable "kubernetes_version" {
69+
description = "AKS Kubernetes version"
70+
type = string
71+
default = "1.30"
72+
}
73+
74+
variable "ssh_public_key" {
75+
description = "SSH public key for AKS nodes"
76+
type = string
77+
}
78+
79+
variable "aks_admin_username" {
80+
description = "Linux admin username for AKS nodes"
81+
type = string
82+
default = "azureuser"
83+
}
84+
85+
variable "tags" {
86+
description = "Tags applied to all resources"
87+
type = map(string)
88+
default = {}
89+
}
90+
91+
locals {
92+
tags = merge({
93+
environment = var.environment
94+
team = "ml-engineering"
95+
project = var.app_name
96+
}, var.tags)
97+
}

examples/api-first-startup/terraform/main.tf

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -27,75 +27,6 @@ provider "azurerm" {
2727
subscription_id = var.subscription_id
2828
}
2929

30-
# ==============================================================================
31-
# Variables
32-
# ==============================================================================
33-
34-
variable "subscription_id" {
35-
description = "Azure subscription ID"
36-
type = string
37-
validation {
38-
condition = can(regex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", var.subscription_id))
39-
error_message = "subscription_id must be a valid UUID."
40-
}
41-
}
42-
43-
variable "resource_group_name" {
44-
description = "Resource group to deploy into"
45-
type = string
46-
}
47-
48-
variable "location" {
49-
description = "Azure region"
50-
type = string
51-
default = "eastus2"
52-
}
53-
54-
variable "app_name" {
55-
description = "Application name prefix (lowercase alphanumeric, max 12 chars to fit resource naming limits)"
56-
type = string
57-
validation {
58-
condition = can(regex("^[a-z][a-z0-9]{1,11}$", var.app_name))
59-
error_message = "app_name must be 2-12 lowercase alphanumeric characters, starting with a letter."
60-
}
61-
}
62-
63-
variable "environment" {
64-
description = "Environment: prod or nonprod"
65-
type = string
66-
default = "prod"
67-
validation {
68-
condition = contains(["prod", "nonprod"], var.environment)
69-
error_message = "Environment must be 'prod' or 'nonprod'."
70-
}
71-
}
72-
73-
variable "apim_publisher_email" {
74-
description = "APIM publisher email"
75-
type = string
76-
}
77-
78-
variable "apim_publisher_name" {
79-
description = "APIM publisher name"
80-
type = string
81-
}
82-
83-
variable "tags" {
84-
description = "Tags applied to all resources"
85-
type = map(string)
86-
default = {}
87-
}
88-
89-
locals {
90-
app_service_sku = var.environment == "prod" ? "P1v3" : "B1"
91-
92-
tags = merge({
93-
environment = var.environment
94-
team = "engineering"
95-
project = var.app_name
96-
}, var.tags)
97-
}
98-
9930
# ==============================================================================
10031
# Data source for existing resource group
10132
# ==============================================================================
@@ -354,38 +285,3 @@ resource "azurerm_monitor_diagnostic_setting" "apim" {
354285
category = "GatewayLogs"
355286
}
356287
}
357-
358-
# ==============================================================================
359-
# Outputs
360-
# ==============================================================================
361-
362-
output "app_url" {
363-
description = "HTTPS URL of the App Service API"
364-
value = "https://${azurerm_linux_web_app.this.default_hostname}"
365-
}
366-
367-
output "apim_gateway_url" {
368-
description = "API Management gateway URL for external consumers"
369-
value = azurerm_api_management.this.gateway_url
370-
}
371-
372-
output "cosmos_endpoint" {
373-
description = "Cosmos DB account endpoint URL"
374-
value = azurerm_cosmosdb_account.this.endpoint
375-
}
376-
377-
output "app_insights_connection_string" {
378-
description = "Application Insights connection string (sensitive)"
379-
value = azurerm_application_insights.this.connection_string
380-
sensitive = true
381-
}
382-
383-
output "redis_hostname" {
384-
description = "Redis cache hostname for response caching"
385-
value = azurerm_redis_cache.this.hostname
386-
}
387-
388-
output "key_vault_uri" {
389-
description = "Key Vault URI for secret access"
390-
value = azurerm_key_vault.this.vault_uri
391-
}

0 commit comments

Comments
 (0)