tf-starter 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +421 -0
  3. package/bin/tf-starter.js +88 -0
  4. package/package.json +43 -0
  5. package/scripts/postinstall.js +105 -0
  6. package/setup.py +32 -0
  7. package/tf_starter/__init__.py +3 -0
  8. package/tf_starter/__main__.py +6 -0
  9. package/tf_starter/cli.py +379 -0
  10. package/tf_starter/generator.py +171 -0
  11. package/tf_starter/template_engine.py +80 -0
  12. package/tf_starter/templates/aws/environments/backend.tf.j2 +16 -0
  13. package/tf_starter/templates/aws/environments/main.tf.j2 +85 -0
  14. package/tf_starter/templates/aws/environments/terraform.tfvars.j2 +52 -0
  15. package/tf_starter/templates/aws/environments/variables.tf.j2 +127 -0
  16. package/tf_starter/templates/aws/github/terraform.yml.j2 +133 -0
  17. package/tf_starter/templates/aws/misc/Makefile.j2 +60 -0
  18. package/tf_starter/templates/aws/misc/README.md.j2 +445 -0
  19. package/tf_starter/templates/aws/misc/init.sh.j2 +110 -0
  20. package/tf_starter/templates/aws/misc/pre-commit-config.yaml.j2 +34 -0
  21. package/tf_starter/templates/aws/modules/apigateway/main.tf.j2 +224 -0
  22. package/tf_starter/templates/aws/modules/apigateway/outputs.tf.j2 +28 -0
  23. package/tf_starter/templates/aws/modules/apigateway/variables.tf.j2 +69 -0
  24. package/tf_starter/templates/aws/modules/compute/main.tf.j2 +245 -0
  25. package/tf_starter/templates/aws/modules/compute/outputs.tf.j2 +38 -0
  26. package/tf_starter/templates/aws/modules/compute/variables.tf.j2 +68 -0
  27. package/tf_starter/templates/aws/modules/database/main.tf.j2 +122 -0
  28. package/tf_starter/templates/aws/modules/database/outputs.tf.j2 +33 -0
  29. package/tf_starter/templates/aws/modules/database/variables.tf.j2 +63 -0
  30. package/tf_starter/templates/aws/modules/kubernetes/main.tf.j2 +167 -0
  31. package/tf_starter/templates/aws/modules/kubernetes/outputs.tf.j2 +33 -0
  32. package/tf_starter/templates/aws/modules/kubernetes/variables.tf.j2 +64 -0
  33. package/tf_starter/templates/aws/modules/lambda/main.tf.j2 +215 -0
  34. package/tf_starter/templates/aws/modules/lambda/outputs.tf.j2 +38 -0
  35. package/tf_starter/templates/aws/modules/lambda/variables.tf.j2 +88 -0
  36. package/tf_starter/templates/aws/modules/messaging/main.tf.j2 +85 -0
  37. package/tf_starter/templates/aws/modules/messaging/outputs.tf.j2 +28 -0
  38. package/tf_starter/templates/aws/modules/messaging/variables.tf.j2 +41 -0
  39. package/tf_starter/templates/aws/modules/monitoring/main.tf.j2 +155 -0
  40. package/tf_starter/templates/aws/modules/monitoring/outputs.tf.j2 +23 -0
  41. package/tf_starter/templates/aws/modules/monitoring/variables.tf.j2 +39 -0
  42. package/tf_starter/templates/aws/modules/network/main.tf.j2 +147 -0
  43. package/tf_starter/templates/aws/modules/network/outputs.tf.j2 +33 -0
  44. package/tf_starter/templates/aws/modules/network/variables.tf.j2 +52 -0
  45. package/tf_starter/templates/aws/modules/storage/main.tf.j2 +88 -0
  46. package/tf_starter/templates/aws/modules/storage/outputs.tf.j2 +23 -0
  47. package/tf_starter/templates/aws/modules/storage/variables.tf.j2 +25 -0
  48. package/tf_starter/templates/aws/root/backend.tf.j2 +19 -0
  49. package/tf_starter/templates/aws/root/main.tf.j2 +219 -0
  50. package/tf_starter/templates/aws/root/outputs.tf.j2 +134 -0
  51. package/tf_starter/templates/aws/root/providers.tf.j2 +24 -0
  52. package/tf_starter/templates/aws/root/variables.tf.j2 +300 -0
  53. package/tf_starter/templates/aws/root/versions.tf.j2 +26 -0
  54. package/tf_starter/templates/azure/environments/backend.tf.j2 +11 -0
  55. package/tf_starter/templates/azure/environments/main.tf.j2 +57 -0
  56. package/tf_starter/templates/azure/environments/terraform.tfvars.j2 +14 -0
  57. package/tf_starter/templates/azure/environments/variables.tf.j2 +30 -0
  58. package/tf_starter/templates/azure/github/terraform.yml.j2 +133 -0
  59. package/tf_starter/templates/azure/misc/Makefile.j2 +60 -0
  60. package/tf_starter/templates/azure/misc/README.md.j2 +426 -0
  61. package/tf_starter/templates/azure/misc/init.sh.j2 +110 -0
  62. package/tf_starter/templates/azure/misc/pre-commit-config.yaml.j2 +34 -0
  63. package/tf_starter/templates/azure/modules/apigateway/main.tf.j2 +125 -0
  64. package/tf_starter/templates/azure/modules/apigateway/outputs.tf.j2 +18 -0
  65. package/tf_starter/templates/azure/modules/apigateway/variables.tf.j2 +54 -0
  66. package/tf_starter/templates/azure/modules/compute/main.tf.j2 +114 -0
  67. package/tf_starter/templates/azure/modules/compute/outputs.tf.j2 +9 -0
  68. package/tf_starter/templates/azure/modules/compute/variables.tf.j2 +23 -0
  69. package/tf_starter/templates/azure/modules/database/main.tf.j2 +56 -0
  70. package/tf_starter/templates/azure/modules/database/outputs.tf.j2 +13 -0
  71. package/tf_starter/templates/azure/modules/database/variables.tf.j2 +38 -0
  72. package/tf_starter/templates/azure/modules/kubernetes/main.tf.j2 +50 -0
  73. package/tf_starter/templates/azure/modules/kubernetes/outputs.tf.j2 +19 -0
  74. package/tf_starter/templates/azure/modules/kubernetes/variables.tf.j2 +37 -0
  75. package/tf_starter/templates/azure/modules/lambda/main.tf.j2 +98 -0
  76. package/tf_starter/templates/azure/modules/lambda/outputs.tf.j2 +23 -0
  77. package/tf_starter/templates/azure/modules/lambda/variables.tf.j2 +53 -0
  78. package/tf_starter/templates/azure/modules/messaging/main.tf.j2 +29 -0
  79. package/tf_starter/templates/azure/modules/messaging/outputs.tf.j2 +14 -0
  80. package/tf_starter/templates/azure/modules/messaging/variables.tf.j2 +11 -0
  81. package/tf_starter/templates/azure/modules/monitoring/main.tf.j2 +31 -0
  82. package/tf_starter/templates/azure/modules/monitoring/outputs.tf.j2 +9 -0
  83. package/tf_starter/templates/azure/modules/monitoring/variables.tf.j2 +16 -0
  84. package/tf_starter/templates/azure/modules/network/main.tf.j2 +89 -0
  85. package/tf_starter/templates/azure/modules/network/outputs.tf.j2 +25 -0
  86. package/tf_starter/templates/azure/modules/network/variables.tf.j2 +25 -0
  87. package/tf_starter/templates/azure/modules/storage/main.tf.j2 +41 -0
  88. package/tf_starter/templates/azure/modules/storage/outputs.tf.j2 +17 -0
  89. package/tf_starter/templates/azure/modules/storage/variables.tf.j2 +16 -0
  90. package/tf_starter/templates/azure/root/backend.tf.j2 +11 -0
  91. package/tf_starter/templates/azure/root/main.tf.j2 +181 -0
  92. package/tf_starter/templates/azure/root/outputs.tf.j2 +45 -0
  93. package/tf_starter/templates/azure/root/providers.tf.j2 +18 -0
  94. package/tf_starter/templates/azure/root/variables.tf.j2 +114 -0
  95. package/tf_starter/templates/azure/root/versions.tf.j2 +16 -0
  96. package/tf_starter/templates/gcp/environments/backend.tf.j2 +9 -0
  97. package/tf_starter/templates/gcp/environments/main.tf.j2 +58 -0
  98. package/tf_starter/templates/gcp/environments/terraform.tfvars.j2 +12 -0
  99. package/tf_starter/templates/gcp/environments/variables.tf.j2 +21 -0
  100. package/tf_starter/templates/gcp/github/terraform.yml.j2 +133 -0
  101. package/tf_starter/templates/gcp/misc/Makefile.j2 +60 -0
  102. package/tf_starter/templates/gcp/misc/README.md.j2 +426 -0
  103. package/tf_starter/templates/gcp/misc/init.sh.j2 +110 -0
  104. package/tf_starter/templates/gcp/misc/pre-commit-config.yaml.j2 +34 -0
  105. package/tf_starter/templates/gcp/modules/apigateway/main.tf.j2 +67 -0
  106. package/tf_starter/templates/gcp/modules/apigateway/outputs.tf.j2 +18 -0
  107. package/tf_starter/templates/gcp/modules/apigateway/variables.tf.j2 +34 -0
  108. package/tf_starter/templates/gcp/modules/compute/main.tf.j2 +138 -0
  109. package/tf_starter/templates/gcp/modules/compute/outputs.tf.j2 +13 -0
  110. package/tf_starter/templates/gcp/modules/compute/variables.tf.j2 +33 -0
  111. package/tf_starter/templates/gcp/modules/database/main.tf.j2 +62 -0
  112. package/tf_starter/templates/gcp/modules/database/outputs.tf.j2 +13 -0
  113. package/tf_starter/templates/gcp/modules/database/variables.tf.j2 +29 -0
  114. package/tf_starter/templates/gcp/modules/kubernetes/main.tf.j2 +75 -0
  115. package/tf_starter/templates/gcp/modules/kubernetes/outputs.tf.j2 +14 -0
  116. package/tf_starter/templates/gcp/modules/kubernetes/variables.tf.j2 +38 -0
  117. package/tf_starter/templates/gcp/modules/lambda/main.tf.j2 +122 -0
  118. package/tf_starter/templates/gcp/modules/lambda/outputs.tf.j2 +18 -0
  119. package/tf_starter/templates/gcp/modules/lambda/variables.tf.j2 +77 -0
  120. package/tf_starter/templates/gcp/modules/messaging/main.tf.j2 +44 -0
  121. package/tf_starter/templates/gcp/modules/messaging/outputs.tf.j2 +13 -0
  122. package/tf_starter/templates/gcp/modules/messaging/variables.tf.j2 +20 -0
  123. package/tf_starter/templates/gcp/modules/monitoring/main.tf.j2 +44 -0
  124. package/tf_starter/templates/gcp/modules/monitoring/outputs.tf.j2 +9 -0
  125. package/tf_starter/templates/gcp/modules/monitoring/variables.tf.j2 +13 -0
  126. package/tf_starter/templates/gcp/modules/network/main.tf.j2 +103 -0
  127. package/tf_starter/templates/gcp/modules/network/outputs.tf.j2 +21 -0
  128. package/tf_starter/templates/gcp/modules/network/variables.tf.j2 +22 -0
  129. package/tf_starter/templates/gcp/modules/storage/main.tf.j2 +47 -0
  130. package/tf_starter/templates/gcp/modules/storage/outputs.tf.j2 +13 -0
  131. package/tf_starter/templates/gcp/modules/storage/variables.tf.j2 +16 -0
  132. package/tf_starter/templates/gcp/root/backend.tf.j2 +12 -0
  133. package/tf_starter/templates/gcp/root/main.tf.j2 +210 -0
  134. package/tf_starter/templates/gcp/root/outputs.tf.j2 +61 -0
  135. package/tf_starter/templates/gcp/root/providers.tf.j2 +18 -0
  136. package/tf_starter/templates/gcp/root/variables.tf.j2 +140 -0
  137. package/tf_starter/templates/gcp/root/versions.tf.j2 +23 -0
@@ -0,0 +1,31 @@
1
+ # MONITORING MODULE — Azure Monitor (Azure)
2
+ # Generated by tf-starter
3
+
4
+ locals {
5
+ name_prefix = "${var.project_name}-${var.environment}"
6
+ }
7
+
8
+ resource "azurerm_monitor_action_group" "main" {
9
+ name = "${local.name_prefix}-alerts"
10
+ resource_group_name = var.resource_group_name
11
+ short_name = substr(local.name_prefix, 0, 12)
12
+
13
+ dynamic "email_receiver" {
14
+ for_each = var.alert_email != "" ? [1] : []
15
+ content {
16
+ name = "email-alerts"
17
+ email_address = var.alert_email
18
+ }
19
+ }
20
+
21
+ tags = var.tags
22
+ }
23
+
24
+ resource "azurerm_log_analytics_workspace" "main" {
25
+ name = "${local.name_prefix}-logs"
26
+ resource_group_name = var.resource_group_name
27
+ location = var.location
28
+ sku = "PerGB2018"
29
+ retention_in_days = var.environment == "prod" ? 90 : 30
30
+ tags = var.tags
31
+ }
@@ -0,0 +1,9 @@
1
+ # MONITORING MODULE — Outputs (Azure)
2
+
3
+ output "action_group_id" {
4
+ value = azurerm_monitor_action_group.main.id
5
+ }
6
+
7
+ output "log_analytics_workspace_id" {
8
+ value = azurerm_log_analytics_workspace.main.id
9
+ }
@@ -0,0 +1,16 @@
1
+ # MONITORING MODULE — Variables (Azure)
2
+
3
+ variable "project_name" { type = string }
4
+ variable "environment" { type = string }
5
+ variable "location" { type = string }
6
+ variable "resource_group_name" { type = string }
7
+
8
+ variable "alert_email" {
9
+ type = string
10
+ default = ""
11
+ }
12
+
13
+ variable "tags" {
14
+ type = map(string)
15
+ default = {}
16
+ }
@@ -0,0 +1,89 @@
1
+ # NETWORK MODULE — Resource Group, VNet, Subnets, NSG, NAT Gateway (Azure)
2
+ # Generated by tf-starter
3
+
4
+ locals {
5
+ name_prefix = "${var.project_name}-${var.environment}"
6
+ }
7
+
8
+ resource "azurerm_resource_group" "main" {
9
+ name = "${local.name_prefix}-rg"
10
+ location = var.location
11
+ tags = var.tags
12
+ }
13
+
14
+ resource "azurerm_virtual_network" "main" {
15
+ name = "${local.name_prefix}-vnet"
16
+ resource_group_name = azurerm_resource_group.main.name
17
+ location = azurerm_resource_group.main.location
18
+ address_space = var.vnet_address_space
19
+ tags = var.tags
20
+ }
21
+
22
+ resource "azurerm_subnet" "public" {
23
+ name = "${local.name_prefix}-public"
24
+ resource_group_name = azurerm_resource_group.main.name
25
+ virtual_network_name = azurerm_virtual_network.main.name
26
+ address_prefixes = [var.public_subnet_cidr]
27
+ }
28
+
29
+ resource "azurerm_subnet" "private" {
30
+ name = "${local.name_prefix}-private"
31
+ resource_group_name = azurerm_resource_group.main.name
32
+ virtual_network_name = azurerm_virtual_network.main.name
33
+ address_prefixes = [var.private_subnet_cidr]
34
+
35
+ delegation {
36
+ name = "fs-delegation"
37
+ service_delegation {
38
+ name = "Microsoft.DBforPostgreSQL/flexibleServers"
39
+ actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"]
40
+ }
41
+ }
42
+ }
43
+
44
+ resource "azurerm_network_security_group" "main" {
45
+ name = "${local.name_prefix}-nsg"
46
+ resource_group_name = azurerm_resource_group.main.name
47
+ location = azurerm_resource_group.main.location
48
+
49
+ security_rule {
50
+ name = "AllowHTTP"
51
+ priority = 100
52
+ direction = "Inbound"
53
+ access = "Allow"
54
+ protocol = "Tcp"
55
+ source_port_range = "*"
56
+ destination_port_ranges = ["80", "443"]
57
+ source_address_prefix = "*"
58
+ destination_address_prefix = "*"
59
+ }
60
+
61
+ tags = var.tags
62
+ }
63
+
64
+ resource "azurerm_public_ip" "nat" {
65
+ name = "${local.name_prefix}-nat-ip"
66
+ resource_group_name = azurerm_resource_group.main.name
67
+ location = azurerm_resource_group.main.location
68
+ allocation_method = "Static"
69
+ sku = "Standard"
70
+ tags = var.tags
71
+ }
72
+
73
+ resource "azurerm_nat_gateway" "main" {
74
+ name = "${local.name_prefix}-nat"
75
+ resource_group_name = azurerm_resource_group.main.name
76
+ location = azurerm_resource_group.main.location
77
+ sku_name = "Standard"
78
+ tags = var.tags
79
+ }
80
+
81
+ resource "azurerm_nat_gateway_public_ip_association" "main" {
82
+ nat_gateway_id = azurerm_nat_gateway.main.id
83
+ public_ip_address_id = azurerm_public_ip.nat.id
84
+ }
85
+
86
+ resource "azurerm_subnet_nat_gateway_association" "private" {
87
+ subnet_id = azurerm_subnet.private.id
88
+ nat_gateway_id = azurerm_nat_gateway.main.id
89
+ }
@@ -0,0 +1,25 @@
1
+ # NETWORK MODULE — Outputs (Azure)
2
+
3
+ output "resource_group_name" {
4
+ value = azurerm_resource_group.main.name
5
+ }
6
+
7
+ output "resource_group_location" {
8
+ value = azurerm_resource_group.main.location
9
+ }
10
+
11
+ output "vnet_id" {
12
+ value = azurerm_virtual_network.main.id
13
+ }
14
+
15
+ output "vnet_name" {
16
+ value = azurerm_virtual_network.main.name
17
+ }
18
+
19
+ output "public_subnet_id" {
20
+ value = azurerm_subnet.public.id
21
+ }
22
+
23
+ output "private_subnet_id" {
24
+ value = azurerm_subnet.private.id
25
+ }
@@ -0,0 +1,25 @@
1
+ # NETWORK MODULE — Variables (Azure)
2
+
3
+ variable "project_name" { type = string }
4
+ variable "environment" { type = string }
5
+ variable "location" { type = string }
6
+
7
+ variable "vnet_address_space" {
8
+ type = list(string)
9
+ default = ["10.0.0.0/16"]
10
+ }
11
+
12
+ variable "public_subnet_cidr" {
13
+ type = string
14
+ default = "10.0.1.0/24"
15
+ }
16
+
17
+ variable "private_subnet_cidr" {
18
+ type = string
19
+ default = "10.0.10.0/24"
20
+ }
21
+
22
+ variable "tags" {
23
+ type = map(string)
24
+ default = {}
25
+ }
@@ -0,0 +1,41 @@
1
+ # STORAGE MODULE — Azure Storage Account
2
+ # Generated by tf-starter
3
+
4
+ locals {
5
+ name_prefix = "${var.project_name}-${var.environment}"
6
+ # Storage account names: lowercase, no hyphens, max 24 chars
7
+ storage_account_name = substr(replace("${var.project_name}${var.environment}stor", "-", ""), 0, 24)
8
+ }
9
+
10
+ resource "random_id" "storage_suffix" {
11
+ byte_length = 3
12
+ }
13
+
14
+ resource "azurerm_storage_account" "main" {
15
+ name = "${local.storage_account_name}${random_id.storage_suffix.hex}"
16
+ resource_group_name = var.resource_group_name
17
+ location = var.location
18
+ account_tier = "Standard"
19
+ account_replication_type = "LRS"
20
+ min_tls_version = "TLS1_2"
21
+
22
+ blob_properties {
23
+ versioning_enabled = var.enable_versioning
24
+
25
+ delete_retention_policy {
26
+ days = 30
27
+ }
28
+
29
+ container_delete_retention_policy {
30
+ days = 30
31
+ }
32
+ }
33
+
34
+ tags = var.tags
35
+ }
36
+
37
+ resource "azurerm_storage_container" "main" {
38
+ name = "${local.name_prefix}-container"
39
+ storage_account_name = azurerm_storage_account.main.name
40
+ container_access_type = "private"
41
+ }
@@ -0,0 +1,17 @@
1
+ # STORAGE MODULE — Outputs (Azure)
2
+
3
+ output "storage_account_name" {
4
+ value = azurerm_storage_account.main.name
5
+ }
6
+
7
+ output "storage_account_id" {
8
+ value = azurerm_storage_account.main.id
9
+ }
10
+
11
+ output "primary_blob_endpoint" {
12
+ value = azurerm_storage_account.main.primary_blob_endpoint
13
+ }
14
+
15
+ output "container_name" {
16
+ value = azurerm_storage_container.main.name
17
+ }
@@ -0,0 +1,16 @@
1
+ # STORAGE MODULE — Variables (Azure)
2
+
3
+ variable "project_name" { type = string }
4
+ variable "environment" { type = string }
5
+ variable "location" { type = string }
6
+ variable "resource_group_name" { type = string }
7
+
8
+ variable "enable_versioning" {
9
+ type = bool
10
+ default = true
11
+ }
12
+
13
+ variable "tags" {
14
+ type = map(string)
15
+ default = {}
16
+ }
@@ -0,0 +1,11 @@
1
+ # REMOTE BACKEND — Azure Storage
2
+
3
+ terraform {
4
+ backend "azurerm" {
5
+ ### MUST EDIT THIS ###
6
+ resource_group_name = "{{ project_name }}-tfstate-rg"
7
+ storage_account_name = "{{ project_name | replace('-', '') }}tfstate"
8
+ container_name = "tfstate"
9
+ key = "{{ project_name }}/terraform.tfstate"
10
+ }
11
+ }
@@ -0,0 +1,181 @@
1
+ # ---------------------------------------------------------------------------------------------------------------------
2
+ # ROOT MAIN CONFIGURATION
3
+ # Project: {{ project_name }}
4
+ # Provider: Azure
5
+ # Generated by tf-starter
6
+ # ---------------------------------------------------------------------------------------------------------------------
7
+
8
+ locals {
9
+ project_name = "{{ project_name }}"
10
+ location = var.location
11
+ environment = var.environment
12
+
13
+ common_tags = {
14
+ Project = local.project_name
15
+ Environment = local.environment
16
+ ManagedBy = "terraform"
17
+ Generator = "tf-starter"
18
+ }
19
+ }
20
+
21
+ # ---------------------------------------------------------------------------------------------------------------------
22
+ # NETWORK MODULE (always included)
23
+ # ---------------------------------------------------------------------------------------------------------------------
24
+
25
+ module "network" {
26
+ source = "./modules/network"
27
+
28
+ project_name = local.project_name
29
+ environment = local.environment
30
+ location = local.location
31
+
32
+ vnet_address_space = var.vnet_address_space
33
+ public_subnet_cidr = var.public_subnet_cidr
34
+ private_subnet_cidr = var.private_subnet_cidr
35
+
36
+ tags = local.common_tags
37
+ }
38
+
39
+ {% if "compute" in services %}
40
+ module "compute" {
41
+ source = "./modules/compute"
42
+
43
+ project_name = local.project_name
44
+ environment = local.environment
45
+ location = local.location
46
+ resource_group_name = module.network.resource_group_name
47
+
48
+ subnet_id = module.network.private_subnet_id
49
+ public_subnet_id = module.network.public_subnet_id
50
+ vm_size = var.vm_size
51
+ instance_count = var.vmss_instance_count
52
+
53
+ tags = local.common_tags
54
+ }
55
+ {% endif %}
56
+
57
+ {% if "lambda" in services %}
58
+ # ---------------------------------------------------------------------------------------------------------------------
59
+ # LAMBDA MODULE (Azure Functions)
60
+ # ---------------------------------------------------------------------------------------------------------------------
61
+
62
+ module "lambda" {
63
+ source = "./modules/lambda"
64
+
65
+ project_name = local.project_name
66
+ environment = local.environment
67
+ location = local.location
68
+ resource_group_name = module.network.resource_group_name
69
+
70
+ sku_name = var.function_sku_name
71
+ python_version = var.function_python_version
72
+ app_settings = var.function_app_settings
73
+
74
+ tags = local.common_tags
75
+ }
76
+ {% endif %}
77
+
78
+ {% if "apigateway" in services %}
79
+ # ---------------------------------------------------------------------------------------------------------------------
80
+ # API GATEWAY MODULE (Azure API Management)
81
+ # ---------------------------------------------------------------------------------------------------------------------
82
+
83
+ module "apigateway" {
84
+ source = "./modules/apigateway"
85
+
86
+ project_name = local.project_name
87
+ environment = local.environment
88
+ location = local.location
89
+ resource_group_name = module.network.resource_group_name
90
+
91
+ function_app_hostname = module.lambda.default_hostname
92
+ publisher_name = var.apim_publisher_name
93
+ publisher_email = var.apim_publisher_email
94
+ sku_name = var.apim_sku_name
95
+
96
+ tags = local.common_tags
97
+ }
98
+ {% endif %}
99
+
100
+ {% if "database" in services %}
101
+ module "database" {
102
+ source = "./modules/database"
103
+
104
+ project_name = local.project_name
105
+ environment = local.environment
106
+ location = local.location
107
+ resource_group_name = module.network.resource_group_name
108
+
109
+ subnet_id = module.network.private_subnet_id
110
+ db_sku_name = var.db_sku_name
111
+ db_storage_mb = var.db_storage_mb
112
+ db_name = var.db_name
113
+ db_admin_login = var.db_admin_login
114
+ db_ha = var.environment == "prod" ? true : false
115
+
116
+ tags = local.common_tags
117
+ }
118
+ {% endif %}
119
+
120
+ {% if "kubernetes" in services %}
121
+ module "kubernetes" {
122
+ source = "./modules/kubernetes"
123
+
124
+ project_name = local.project_name
125
+ environment = local.environment
126
+ location = local.location
127
+ resource_group_name = module.network.resource_group_name
128
+
129
+ subnet_id = module.network.private_subnet_id
130
+ kubernetes_version = var.aks_kubernetes_version
131
+ node_vm_size = var.aks_node_vm_size
132
+ node_count = var.aks_node_count
133
+ node_min_count = var.aks_node_min_count
134
+ node_max_count = var.aks_node_max_count
135
+
136
+ tags = local.common_tags
137
+ }
138
+ {% endif %}
139
+
140
+ {% if "monitoring" in services %}
141
+ module "monitoring" {
142
+ source = "./modules/monitoring"
143
+
144
+ project_name = local.project_name
145
+ environment = local.environment
146
+ location = local.location
147
+ resource_group_name = module.network.resource_group_name
148
+
149
+ alert_email = var.alert_email
150
+
151
+ tags = local.common_tags
152
+ }
153
+ {% endif %}
154
+
155
+ {% if "messaging" in services %}
156
+ module "messaging" {
157
+ source = "./modules/messaging"
158
+
159
+ project_name = local.project_name
160
+ environment = local.environment
161
+ location = local.location
162
+ resource_group_name = module.network.resource_group_name
163
+
164
+ tags = local.common_tags
165
+ }
166
+ {% endif %}
167
+
168
+ {% if "storage" in services %}
169
+ module "storage" {
170
+ source = "./modules/storage"
171
+
172
+ project_name = local.project_name
173
+ environment = local.environment
174
+ location = local.location
175
+ resource_group_name = module.network.resource_group_name
176
+
177
+ enable_versioning = var.storage_enable_versioning
178
+
179
+ tags = local.common_tags
180
+ }
181
+ {% endif %}
@@ -0,0 +1,45 @@
1
+ # ROOT OUTPUTS — Azure
2
+ # Generated by tf-starter
3
+
4
+ output "resource_group_name" {
5
+ value = module.network.resource_group_name
6
+ }
7
+
8
+ output "vnet_id" {
9
+ value = module.network.vnet_id
10
+ }
11
+
12
+ {% if "compute" in services %}
13
+ output "app_gateway_public_ip" {
14
+ value = module.compute.app_gateway_public_ip
15
+ }
16
+ {% endif %}
17
+
18
+ {% if "database" in services %}
19
+ output "db_fqdn" {
20
+ value = module.database.fqdn
21
+ }
22
+ {% endif %}
23
+
24
+ {% if "kubernetes" in services %}
25
+ output "aks_cluster_name" {
26
+ value = module.kubernetes.cluster_name
27
+ }
28
+
29
+ output "aks_kube_config" {
30
+ value = module.kubernetes.kube_config
31
+ sensitive = true
32
+ }
33
+ {% endif %}
34
+
35
+ {% if "messaging" in services %}
36
+ output "servicebus_queue_id" {
37
+ value = module.messaging.queue_id
38
+ }
39
+ {% endif %}
40
+
41
+ {% if "storage" in services %}
42
+ output "storage_account_name" {
43
+ value = module.storage.storage_account_name
44
+ }
45
+ {% endif %}
@@ -0,0 +1,18 @@
1
+ # PROVIDER CONFIGURATION — Azure
2
+ # Generated by tf-starter
3
+
4
+ provider "azurerm" {
5
+ features {
6
+ resource_group {
7
+ prevent_deletion_if_contains_resources = true
8
+ }
9
+ {% if "database" in services %}
10
+ postgresql_flexible_server {
11
+ restart_server_on_configuration_value_change = true
12
+ }
13
+ {% endif %}
14
+ }
15
+
16
+ ### MUST EDIT THIS ###
17
+ # subscription_id = "your-subscription-id"
18
+ }
@@ -0,0 +1,114 @@
1
+ # ROOT VARIABLES — Azure
2
+ # Generated by tf-starter
3
+
4
+ variable "location" {
5
+ description = "Azure region"
6
+ type = string
7
+ default = "{{ region }}"
8
+ }
9
+
10
+ variable "environment" {
11
+ description = "Deployment environment"
12
+ type = string
13
+ default = "dev"
14
+
15
+ validation {
16
+ condition = contains({{ environments | tf_list }}, var.environment)
17
+ error_message = "Environment must be one of: {{ environments | join(', ') }}."
18
+ }
19
+ }
20
+
21
+ variable "vnet_address_space" {
22
+ description = "VNet address space"
23
+ type = list(string)
24
+ default = ["10.0.0.0/16"]
25
+ }
26
+
27
+ variable "public_subnet_cidr" {
28
+ description = "Public subnet CIDR"
29
+ type = string
30
+ default = "10.0.1.0/24"
31
+ }
32
+
33
+ variable "private_subnet_cidr" {
34
+ description = "Private subnet CIDR"
35
+ type = string
36
+ default = "10.0.10.0/24"
37
+ }
38
+
39
+ {% if "compute" in services %}
40
+ variable "vm_size" {
41
+ type = string
42
+ default = "Standard_B2s"
43
+ }
44
+
45
+ variable "vmss_instance_count" {
46
+ type = number
47
+ default = 2
48
+ }
49
+ {% endif %}
50
+
51
+ {% if "database" in services %}
52
+ variable "db_sku_name" {
53
+ type = string
54
+ default = "GP_Standard_D2s_v3"
55
+ }
56
+
57
+ variable "db_storage_mb" {
58
+ type = number
59
+ default = 32768
60
+ }
61
+
62
+ variable "db_name" {
63
+ type = string
64
+ default = "{{ project_name | replace('-', '_') }}_db"
65
+ }
66
+
67
+ variable "db_admin_login" {
68
+ type = string
69
+ default = "dbadmin"
70
+ sensitive = true
71
+ }
72
+ {% endif %}
73
+
74
+ {% if "kubernetes" in services %}
75
+ variable "aks_kubernetes_version" {
76
+ type = string
77
+ default = "1.29"
78
+ }
79
+
80
+ variable "aks_node_vm_size" {
81
+ type = string
82
+ default = "Standard_D4s_v3"
83
+ }
84
+
85
+ variable "aks_node_count" {
86
+ type = number
87
+ default = 2
88
+ }
89
+
90
+ variable "aks_node_min_count" {
91
+ type = number
92
+ default = 1
93
+ }
94
+
95
+ variable "aks_node_max_count" {
96
+ type = number
97
+ default = 5
98
+ }
99
+ {% endif %}
100
+
101
+ {% if "monitoring" in services %}
102
+ variable "alert_email" {
103
+ type = string
104
+ default = ""
105
+ ### MUST EDIT THIS ###
106
+ }
107
+ {% endif %}
108
+
109
+ {% if "storage" in services %}
110
+ variable "storage_enable_versioning" {
111
+ type = bool
112
+ default = true
113
+ }
114
+ {% endif %}
@@ -0,0 +1,16 @@
1
+ # TERRAFORM AND PROVIDER VERSIONS — Azure
2
+
3
+ terraform {
4
+ required_version = ">= 1.6.0"
5
+
6
+ required_providers {
7
+ azurerm = {
8
+ source = "hashicorp/azurerm"
9
+ version = "~> 3.95"
10
+ }
11
+ random = {
12
+ source = "hashicorp/random"
13
+ version = "~> 3.6"
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,9 @@
1
+ # REMOTE BACKEND — {{ environment | upper }} (GCS)
2
+
3
+ terraform {
4
+ backend "gcs" {
5
+ ### MUST EDIT THIS ###
6
+ bucket = "{{ project_name }}-terraform-state"
7
+ prefix = "{{ project_name }}/{{ environment }}/terraform.tfstate"
8
+ }
9
+ }