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.
- package/LICENSE +21 -0
- package/README.md +421 -0
- package/bin/tf-starter.js +88 -0
- package/package.json +43 -0
- package/scripts/postinstall.js +105 -0
- package/setup.py +32 -0
- package/tf_starter/__init__.py +3 -0
- package/tf_starter/__main__.py +6 -0
- package/tf_starter/cli.py +379 -0
- package/tf_starter/generator.py +171 -0
- package/tf_starter/template_engine.py +80 -0
- package/tf_starter/templates/aws/environments/backend.tf.j2 +16 -0
- package/tf_starter/templates/aws/environments/main.tf.j2 +85 -0
- package/tf_starter/templates/aws/environments/terraform.tfvars.j2 +52 -0
- package/tf_starter/templates/aws/environments/variables.tf.j2 +127 -0
- package/tf_starter/templates/aws/github/terraform.yml.j2 +133 -0
- package/tf_starter/templates/aws/misc/Makefile.j2 +60 -0
- package/tf_starter/templates/aws/misc/README.md.j2 +445 -0
- package/tf_starter/templates/aws/misc/init.sh.j2 +110 -0
- package/tf_starter/templates/aws/misc/pre-commit-config.yaml.j2 +34 -0
- package/tf_starter/templates/aws/modules/apigateway/main.tf.j2 +224 -0
- package/tf_starter/templates/aws/modules/apigateway/outputs.tf.j2 +28 -0
- package/tf_starter/templates/aws/modules/apigateway/variables.tf.j2 +69 -0
- package/tf_starter/templates/aws/modules/compute/main.tf.j2 +245 -0
- package/tf_starter/templates/aws/modules/compute/outputs.tf.j2 +38 -0
- package/tf_starter/templates/aws/modules/compute/variables.tf.j2 +68 -0
- package/tf_starter/templates/aws/modules/database/main.tf.j2 +122 -0
- package/tf_starter/templates/aws/modules/database/outputs.tf.j2 +33 -0
- package/tf_starter/templates/aws/modules/database/variables.tf.j2 +63 -0
- package/tf_starter/templates/aws/modules/kubernetes/main.tf.j2 +167 -0
- package/tf_starter/templates/aws/modules/kubernetes/outputs.tf.j2 +33 -0
- package/tf_starter/templates/aws/modules/kubernetes/variables.tf.j2 +64 -0
- package/tf_starter/templates/aws/modules/lambda/main.tf.j2 +215 -0
- package/tf_starter/templates/aws/modules/lambda/outputs.tf.j2 +38 -0
- package/tf_starter/templates/aws/modules/lambda/variables.tf.j2 +88 -0
- package/tf_starter/templates/aws/modules/messaging/main.tf.j2 +85 -0
- package/tf_starter/templates/aws/modules/messaging/outputs.tf.j2 +28 -0
- package/tf_starter/templates/aws/modules/messaging/variables.tf.j2 +41 -0
- package/tf_starter/templates/aws/modules/monitoring/main.tf.j2 +155 -0
- package/tf_starter/templates/aws/modules/monitoring/outputs.tf.j2 +23 -0
- package/tf_starter/templates/aws/modules/monitoring/variables.tf.j2 +39 -0
- package/tf_starter/templates/aws/modules/network/main.tf.j2 +147 -0
- package/tf_starter/templates/aws/modules/network/outputs.tf.j2 +33 -0
- package/tf_starter/templates/aws/modules/network/variables.tf.j2 +52 -0
- package/tf_starter/templates/aws/modules/storage/main.tf.j2 +88 -0
- package/tf_starter/templates/aws/modules/storage/outputs.tf.j2 +23 -0
- package/tf_starter/templates/aws/modules/storage/variables.tf.j2 +25 -0
- package/tf_starter/templates/aws/root/backend.tf.j2 +19 -0
- package/tf_starter/templates/aws/root/main.tf.j2 +219 -0
- package/tf_starter/templates/aws/root/outputs.tf.j2 +134 -0
- package/tf_starter/templates/aws/root/providers.tf.j2 +24 -0
- package/tf_starter/templates/aws/root/variables.tf.j2 +300 -0
- package/tf_starter/templates/aws/root/versions.tf.j2 +26 -0
- package/tf_starter/templates/azure/environments/backend.tf.j2 +11 -0
- package/tf_starter/templates/azure/environments/main.tf.j2 +57 -0
- package/tf_starter/templates/azure/environments/terraform.tfvars.j2 +14 -0
- package/tf_starter/templates/azure/environments/variables.tf.j2 +30 -0
- package/tf_starter/templates/azure/github/terraform.yml.j2 +133 -0
- package/tf_starter/templates/azure/misc/Makefile.j2 +60 -0
- package/tf_starter/templates/azure/misc/README.md.j2 +426 -0
- package/tf_starter/templates/azure/misc/init.sh.j2 +110 -0
- package/tf_starter/templates/azure/misc/pre-commit-config.yaml.j2 +34 -0
- package/tf_starter/templates/azure/modules/apigateway/main.tf.j2 +125 -0
- package/tf_starter/templates/azure/modules/apigateway/outputs.tf.j2 +18 -0
- package/tf_starter/templates/azure/modules/apigateway/variables.tf.j2 +54 -0
- package/tf_starter/templates/azure/modules/compute/main.tf.j2 +114 -0
- package/tf_starter/templates/azure/modules/compute/outputs.tf.j2 +9 -0
- package/tf_starter/templates/azure/modules/compute/variables.tf.j2 +23 -0
- package/tf_starter/templates/azure/modules/database/main.tf.j2 +56 -0
- package/tf_starter/templates/azure/modules/database/outputs.tf.j2 +13 -0
- package/tf_starter/templates/azure/modules/database/variables.tf.j2 +38 -0
- package/tf_starter/templates/azure/modules/kubernetes/main.tf.j2 +50 -0
- package/tf_starter/templates/azure/modules/kubernetes/outputs.tf.j2 +19 -0
- package/tf_starter/templates/azure/modules/kubernetes/variables.tf.j2 +37 -0
- package/tf_starter/templates/azure/modules/lambda/main.tf.j2 +98 -0
- package/tf_starter/templates/azure/modules/lambda/outputs.tf.j2 +23 -0
- package/tf_starter/templates/azure/modules/lambda/variables.tf.j2 +53 -0
- package/tf_starter/templates/azure/modules/messaging/main.tf.j2 +29 -0
- package/tf_starter/templates/azure/modules/messaging/outputs.tf.j2 +14 -0
- package/tf_starter/templates/azure/modules/messaging/variables.tf.j2 +11 -0
- package/tf_starter/templates/azure/modules/monitoring/main.tf.j2 +31 -0
- package/tf_starter/templates/azure/modules/monitoring/outputs.tf.j2 +9 -0
- package/tf_starter/templates/azure/modules/monitoring/variables.tf.j2 +16 -0
- package/tf_starter/templates/azure/modules/network/main.tf.j2 +89 -0
- package/tf_starter/templates/azure/modules/network/outputs.tf.j2 +25 -0
- package/tf_starter/templates/azure/modules/network/variables.tf.j2 +25 -0
- package/tf_starter/templates/azure/modules/storage/main.tf.j2 +41 -0
- package/tf_starter/templates/azure/modules/storage/outputs.tf.j2 +17 -0
- package/tf_starter/templates/azure/modules/storage/variables.tf.j2 +16 -0
- package/tf_starter/templates/azure/root/backend.tf.j2 +11 -0
- package/tf_starter/templates/azure/root/main.tf.j2 +181 -0
- package/tf_starter/templates/azure/root/outputs.tf.j2 +45 -0
- package/tf_starter/templates/azure/root/providers.tf.j2 +18 -0
- package/tf_starter/templates/azure/root/variables.tf.j2 +114 -0
- package/tf_starter/templates/azure/root/versions.tf.j2 +16 -0
- package/tf_starter/templates/gcp/environments/backend.tf.j2 +9 -0
- package/tf_starter/templates/gcp/environments/main.tf.j2 +58 -0
- package/tf_starter/templates/gcp/environments/terraform.tfvars.j2 +12 -0
- package/tf_starter/templates/gcp/environments/variables.tf.j2 +21 -0
- package/tf_starter/templates/gcp/github/terraform.yml.j2 +133 -0
- package/tf_starter/templates/gcp/misc/Makefile.j2 +60 -0
- package/tf_starter/templates/gcp/misc/README.md.j2 +426 -0
- package/tf_starter/templates/gcp/misc/init.sh.j2 +110 -0
- package/tf_starter/templates/gcp/misc/pre-commit-config.yaml.j2 +34 -0
- package/tf_starter/templates/gcp/modules/apigateway/main.tf.j2 +67 -0
- package/tf_starter/templates/gcp/modules/apigateway/outputs.tf.j2 +18 -0
- package/tf_starter/templates/gcp/modules/apigateway/variables.tf.j2 +34 -0
- package/tf_starter/templates/gcp/modules/compute/main.tf.j2 +138 -0
- package/tf_starter/templates/gcp/modules/compute/outputs.tf.j2 +13 -0
- package/tf_starter/templates/gcp/modules/compute/variables.tf.j2 +33 -0
- package/tf_starter/templates/gcp/modules/database/main.tf.j2 +62 -0
- package/tf_starter/templates/gcp/modules/database/outputs.tf.j2 +13 -0
- package/tf_starter/templates/gcp/modules/database/variables.tf.j2 +29 -0
- package/tf_starter/templates/gcp/modules/kubernetes/main.tf.j2 +75 -0
- package/tf_starter/templates/gcp/modules/kubernetes/outputs.tf.j2 +14 -0
- package/tf_starter/templates/gcp/modules/kubernetes/variables.tf.j2 +38 -0
- package/tf_starter/templates/gcp/modules/lambda/main.tf.j2 +122 -0
- package/tf_starter/templates/gcp/modules/lambda/outputs.tf.j2 +18 -0
- package/tf_starter/templates/gcp/modules/lambda/variables.tf.j2 +77 -0
- package/tf_starter/templates/gcp/modules/messaging/main.tf.j2 +44 -0
- package/tf_starter/templates/gcp/modules/messaging/outputs.tf.j2 +13 -0
- package/tf_starter/templates/gcp/modules/messaging/variables.tf.j2 +20 -0
- package/tf_starter/templates/gcp/modules/monitoring/main.tf.j2 +44 -0
- package/tf_starter/templates/gcp/modules/monitoring/outputs.tf.j2 +9 -0
- package/tf_starter/templates/gcp/modules/monitoring/variables.tf.j2 +13 -0
- package/tf_starter/templates/gcp/modules/network/main.tf.j2 +103 -0
- package/tf_starter/templates/gcp/modules/network/outputs.tf.j2 +21 -0
- package/tf_starter/templates/gcp/modules/network/variables.tf.j2 +22 -0
- package/tf_starter/templates/gcp/modules/storage/main.tf.j2 +47 -0
- package/tf_starter/templates/gcp/modules/storage/outputs.tf.j2 +13 -0
- package/tf_starter/templates/gcp/modules/storage/variables.tf.j2 +16 -0
- package/tf_starter/templates/gcp/root/backend.tf.j2 +12 -0
- package/tf_starter/templates/gcp/root/main.tf.j2 +210 -0
- package/tf_starter/templates/gcp/root/outputs.tf.j2 +61 -0
- package/tf_starter/templates/gcp/root/providers.tf.j2 +18 -0
- package/tf_starter/templates/gcp/root/variables.tf.j2 +140 -0
- package/tf_starter/templates/gcp/root/versions.tf.j2 +23 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
2
|
+
# API GATEWAY MODULE (Azure API Management) — Outputs
|
|
3
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
output "apim_gateway_url" {
|
|
6
|
+
description = "Gateway URL of the API Management instance"
|
|
7
|
+
value = azurerm_api_management.main.gateway_url
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
output "apim_name" {
|
|
11
|
+
description = "Name of the API Management instance"
|
|
12
|
+
value = azurerm_api_management.main.name
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
output "apim_id" {
|
|
16
|
+
description = "ID of the API Management instance"
|
|
17
|
+
value = azurerm_api_management.main.id
|
|
18
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
2
|
+
# API GATEWAY MODULE (Azure API Management) — Variables
|
|
3
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
variable "project_name" {
|
|
6
|
+
description = "Name of the project"
|
|
7
|
+
type = string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
variable "environment" {
|
|
11
|
+
description = "Deployment environment"
|
|
12
|
+
type = string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
variable "location" {
|
|
16
|
+
description = "Azure region"
|
|
17
|
+
type = string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
variable "resource_group_name" {
|
|
21
|
+
description = "Name of the resource group"
|
|
22
|
+
type = string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
variable "function_app_hostname" {
|
|
26
|
+
description = "Default hostname of the Function App"
|
|
27
|
+
type = string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
variable "publisher_name" {
|
|
31
|
+
description = "Publisher name for API Management"
|
|
32
|
+
type = string
|
|
33
|
+
default = "DevOps Team"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
variable "publisher_email" {
|
|
37
|
+
description = "Publisher email for API Management"
|
|
38
|
+
type = string
|
|
39
|
+
default = "admin@example.com"
|
|
40
|
+
|
|
41
|
+
### MUST EDIT THIS ###
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
variable "sku_name" {
|
|
45
|
+
description = "API Management SKU (Consumption, Developer, Basic, Standard, Premium)"
|
|
46
|
+
type = string
|
|
47
|
+
default = "Consumption_0"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
variable "tags" {
|
|
51
|
+
description = "Common resource tags"
|
|
52
|
+
type = map(string)
|
|
53
|
+
default = {}
|
|
54
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# COMPUTE MODULE — VMSS + Application Gateway (Azure)
|
|
2
|
+
# Generated by tf-starter
|
|
3
|
+
|
|
4
|
+
locals {
|
|
5
|
+
name_prefix = "${var.project_name}-${var.environment}"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
resource "azurerm_public_ip" "appgw" {
|
|
9
|
+
name = "${local.name_prefix}-appgw-ip"
|
|
10
|
+
resource_group_name = var.resource_group_name
|
|
11
|
+
location = var.location
|
|
12
|
+
allocation_method = "Static"
|
|
13
|
+
sku = "Standard"
|
|
14
|
+
tags = var.tags
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
resource "azurerm_application_gateway" "main" {
|
|
18
|
+
name = "${local.name_prefix}-appgw"
|
|
19
|
+
resource_group_name = var.resource_group_name
|
|
20
|
+
location = var.location
|
|
21
|
+
|
|
22
|
+
sku {
|
|
23
|
+
name = "Standard_v2"
|
|
24
|
+
tier = "Standard_v2"
|
|
25
|
+
capacity = 2
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
gateway_ip_configuration {
|
|
29
|
+
name = "gateway-ip-config"
|
|
30
|
+
subnet_id = var.public_subnet_id
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
frontend_port {
|
|
34
|
+
name = "http-port"
|
|
35
|
+
port = 80
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
frontend_ip_configuration {
|
|
39
|
+
name = "frontend-ip"
|
|
40
|
+
public_ip_address_id = azurerm_public_ip.appgw.id
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
backend_address_pool {
|
|
44
|
+
name = "backend-pool"
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
backend_http_settings {
|
|
48
|
+
name = "http-settings"
|
|
49
|
+
cookie_based_affinity = "Disabled"
|
|
50
|
+
port = 80
|
|
51
|
+
protocol = "Http"
|
|
52
|
+
request_timeout = 30
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
http_listener {
|
|
56
|
+
name = "http-listener"
|
|
57
|
+
frontend_ip_configuration_name = "frontend-ip"
|
|
58
|
+
frontend_port_name = "http-port"
|
|
59
|
+
protocol = "Http"
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
request_routing_rule {
|
|
63
|
+
name = "routing-rule"
|
|
64
|
+
priority = 100
|
|
65
|
+
rule_type = "Basic"
|
|
66
|
+
http_listener_name = "http-listener"
|
|
67
|
+
backend_address_pool_name = "backend-pool"
|
|
68
|
+
backend_http_settings_name = "http-settings"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
tags = var.tags
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
resource "azurerm_linux_virtual_machine_scale_set" "main" {
|
|
75
|
+
name = "${local.name_prefix}-vmss"
|
|
76
|
+
resource_group_name = var.resource_group_name
|
|
77
|
+
location = var.location
|
|
78
|
+
sku = var.vm_size
|
|
79
|
+
instances = var.instance_count
|
|
80
|
+
admin_username = "azureadmin"
|
|
81
|
+
|
|
82
|
+
admin_ssh_key {
|
|
83
|
+
username = "azureadmin"
|
|
84
|
+
### MUST EDIT THIS ###
|
|
85
|
+
public_key = file("~/.ssh/id_rsa.pub")
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
source_image_reference {
|
|
89
|
+
publisher = "Canonical"
|
|
90
|
+
offer = "0001-com-ubuntu-server-jammy"
|
|
91
|
+
sku = "22_04-lts-gen2"
|
|
92
|
+
version = "latest"
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
os_disk {
|
|
96
|
+
storage_account_type = "Standard_LRS"
|
|
97
|
+
caching = "ReadWrite"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
network_interface {
|
|
101
|
+
name = "nic"
|
|
102
|
+
primary = true
|
|
103
|
+
|
|
104
|
+
ip_configuration {
|
|
105
|
+
name = "internal"
|
|
106
|
+
primary = true
|
|
107
|
+
subnet_id = var.subnet_id
|
|
108
|
+
|
|
109
|
+
application_gateway_backend_address_pool_ids = azurerm_application_gateway.main.backend_address_pool[*].id
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
tags = var.tags
|
|
114
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# COMPUTE 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
|
+
variable "subnet_id" { type = string }
|
|
8
|
+
variable "public_subnet_id" { type = string }
|
|
9
|
+
|
|
10
|
+
variable "vm_size" {
|
|
11
|
+
type = string
|
|
12
|
+
default = "Standard_B2s"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
variable "instance_count" {
|
|
16
|
+
type = number
|
|
17
|
+
default = 2
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
variable "tags" {
|
|
21
|
+
type = map(string)
|
|
22
|
+
default = {}
|
|
23
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# DATABASE MODULE — PostgreSQL Flexible Server (Azure)
|
|
2
|
+
# Generated by tf-starter
|
|
3
|
+
|
|
4
|
+
locals {
|
|
5
|
+
name_prefix = "${var.project_name}-${var.environment}"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
resource "azurerm_private_dns_zone" "postgres" {
|
|
9
|
+
name = "${local.name_prefix}.postgres.database.azure.com"
|
|
10
|
+
resource_group_name = var.resource_group_name
|
|
11
|
+
tags = var.tags
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
resource "azurerm_private_dns_zone_virtual_network_link" "postgres" {
|
|
15
|
+
name = "${local.name_prefix}-dns-link"
|
|
16
|
+
private_dns_zone_name = azurerm_private_dns_zone.postgres.name
|
|
17
|
+
resource_group_name = var.resource_group_name
|
|
18
|
+
virtual_network_id = var.vnet_id
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
resource "random_password" "db_password" {
|
|
22
|
+
length = 24
|
|
23
|
+
special = true
|
|
24
|
+
override_special = "!#$%&*()-_=+[]{}|:?"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
resource "azurerm_postgresql_flexible_server" "main" {
|
|
28
|
+
name = "${local.name_prefix}-postgres"
|
|
29
|
+
resource_group_name = var.resource_group_name
|
|
30
|
+
location = var.location
|
|
31
|
+
version = "16"
|
|
32
|
+
delegated_subnet_id = var.subnet_id
|
|
33
|
+
private_dns_zone_id = azurerm_private_dns_zone.postgres.id
|
|
34
|
+
administrator_login = var.db_admin_login
|
|
35
|
+
administrator_password = random_password.db_password.result
|
|
36
|
+
|
|
37
|
+
storage_mb = var.db_storage_mb
|
|
38
|
+
sku_name = var.db_sku_name
|
|
39
|
+
|
|
40
|
+
high_availability {
|
|
41
|
+
mode = var.db_ha ? "ZoneRedundant" : "Disabled"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
backup_retention_days = var.environment == "prod" ? 35 : 7
|
|
45
|
+
|
|
46
|
+
tags = var.tags
|
|
47
|
+
|
|
48
|
+
depends_on = [azurerm_private_dns_zone_virtual_network_link.postgres]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
resource "azurerm_postgresql_flexible_server_database" "main" {
|
|
52
|
+
name = var.db_name
|
|
53
|
+
server_id = azurerm_postgresql_flexible_server.main.id
|
|
54
|
+
charset = "UTF8"
|
|
55
|
+
collation = "en_US.utf8"
|
|
56
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# DATABASE MODULE — Outputs (Azure)
|
|
2
|
+
|
|
3
|
+
output "fqdn" {
|
|
4
|
+
value = azurerm_postgresql_flexible_server.main.fqdn
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
output "server_id" {
|
|
8
|
+
value = azurerm_postgresql_flexible_server.main.id
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
output "db_name" {
|
|
12
|
+
value = azurerm_postgresql_flexible_server_database.main.name
|
|
13
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# DATABASE 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
|
+
variable "subnet_id" { type = string }
|
|
8
|
+
variable "vnet_id" {
|
|
9
|
+
type = string
|
|
10
|
+
default = ""
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
variable "db_sku_name" {
|
|
14
|
+
type = string
|
|
15
|
+
default = "GP_Standard_D2s_v3"
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
variable "db_storage_mb" {
|
|
19
|
+
type = number
|
|
20
|
+
default = 32768
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
variable "db_name" { type = string }
|
|
24
|
+
|
|
25
|
+
variable "db_admin_login" {
|
|
26
|
+
type = string
|
|
27
|
+
sensitive = true
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
variable "db_ha" {
|
|
31
|
+
type = bool
|
|
32
|
+
default = false
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
variable "tags" {
|
|
36
|
+
type = map(string)
|
|
37
|
+
default = {}
|
|
38
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# KUBERNETES MODULE — AKS (Azure)
|
|
2
|
+
# Generated by tf-starter
|
|
3
|
+
|
|
4
|
+
locals {
|
|
5
|
+
name_prefix = "${var.project_name}-${var.environment}"
|
|
6
|
+
cluster_name = "${local.name_prefix}-aks"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
resource "azurerm_kubernetes_cluster" "main" {
|
|
10
|
+
name = local.cluster_name
|
|
11
|
+
resource_group_name = var.resource_group_name
|
|
12
|
+
location = var.location
|
|
13
|
+
dns_prefix = local.name_prefix
|
|
14
|
+
kubernetes_version = var.kubernetes_version
|
|
15
|
+
|
|
16
|
+
default_node_pool {
|
|
17
|
+
name = "default"
|
|
18
|
+
node_count = var.node_count
|
|
19
|
+
vm_size = var.node_vm_size
|
|
20
|
+
vnet_subnet_id = var.subnet_id
|
|
21
|
+
enable_auto_scaling = true
|
|
22
|
+
min_count = var.node_min_count
|
|
23
|
+
max_count = var.node_max_count
|
|
24
|
+
os_disk_size_gb = 50
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
identity {
|
|
28
|
+
type = "SystemAssigned"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
network_profile {
|
|
32
|
+
network_plugin = "azure"
|
|
33
|
+
load_balancer_sku = "standard"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
oms_agent {
|
|
37
|
+
log_analytics_workspace_id = azurerm_log_analytics_workspace.aks.id
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
tags = var.tags
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
resource "azurerm_log_analytics_workspace" "aks" {
|
|
44
|
+
name = "${local.name_prefix}-aks-logs"
|
|
45
|
+
resource_group_name = var.resource_group_name
|
|
46
|
+
location = var.location
|
|
47
|
+
sku = "PerGB2018"
|
|
48
|
+
retention_in_days = 30
|
|
49
|
+
tags = var.tags
|
|
50
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# KUBERNETES MODULE — Outputs (Azure)
|
|
2
|
+
|
|
3
|
+
output "cluster_name" {
|
|
4
|
+
value = azurerm_kubernetes_cluster.main.name
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
output "cluster_id" {
|
|
8
|
+
value = azurerm_kubernetes_cluster.main.id
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
output "kube_config" {
|
|
12
|
+
value = azurerm_kubernetes_cluster.main.kube_config_raw
|
|
13
|
+
sensitive = true
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
output "client_certificate" {
|
|
17
|
+
value = azurerm_kubernetes_cluster.main.kube_config[0].client_certificate
|
|
18
|
+
sensitive = true
|
|
19
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# KUBERNETES 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
|
+
variable "subnet_id" { type = string }
|
|
8
|
+
|
|
9
|
+
variable "kubernetes_version" {
|
|
10
|
+
type = string
|
|
11
|
+
default = "1.29"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
variable "node_vm_size" {
|
|
15
|
+
type = string
|
|
16
|
+
default = "Standard_D4s_v3"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
variable "node_count" {
|
|
20
|
+
type = number
|
|
21
|
+
default = 2
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
variable "node_min_count" {
|
|
25
|
+
type = number
|
|
26
|
+
default = 1
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
variable "node_max_count" {
|
|
30
|
+
type = number
|
|
31
|
+
default = 5
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
variable "tags" {
|
|
35
|
+
type = map(string)
|
|
36
|
+
default = {}
|
|
37
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
2
|
+
# LAMBDA MODULE — Azure Function App
|
|
3
|
+
# Project: {{ project_name }}
|
|
4
|
+
# Generated by tf-starter
|
|
5
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
locals {
|
|
8
|
+
name_prefix = "${var.project_name}-${var.environment}"
|
|
9
|
+
function_name = "${local.name_prefix}-func"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
13
|
+
# STORAGE ACCOUNT (required by Function App)
|
|
14
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
resource "azurerm_storage_account" "function" {
|
|
17
|
+
name = replace("${local.name_prefix}fn", "-", "")
|
|
18
|
+
resource_group_name = var.resource_group_name
|
|
19
|
+
location = var.location
|
|
20
|
+
account_tier = "Standard"
|
|
21
|
+
account_replication_type = "LRS"
|
|
22
|
+
|
|
23
|
+
tags = var.tags
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
27
|
+
# APP SERVICE PLAN (Consumption / Premium)
|
|
28
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
resource "azurerm_service_plan" "function" {
|
|
31
|
+
name = "${local.function_name}-plan"
|
|
32
|
+
resource_group_name = var.resource_group_name
|
|
33
|
+
location = var.location
|
|
34
|
+
os_type = "Linux"
|
|
35
|
+
sku_name = var.sku_name
|
|
36
|
+
|
|
37
|
+
tags = var.tags
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
41
|
+
# APPLICATION INSIGHTS
|
|
42
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
resource "azurerm_application_insights" "function" {
|
|
45
|
+
name = "${local.function_name}-insights"
|
|
46
|
+
resource_group_name = var.resource_group_name
|
|
47
|
+
location = var.location
|
|
48
|
+
application_type = "web"
|
|
49
|
+
|
|
50
|
+
tags = var.tags
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
54
|
+
# FUNCTION APP
|
|
55
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
resource "azurerm_linux_function_app" "main" {
|
|
58
|
+
name = local.function_name
|
|
59
|
+
resource_group_name = var.resource_group_name
|
|
60
|
+
location = var.location
|
|
61
|
+
service_plan_id = azurerm_service_plan.function.id
|
|
62
|
+
|
|
63
|
+
storage_account_name = azurerm_storage_account.function.name
|
|
64
|
+
storage_account_access_key = azurerm_storage_account.function.primary_access_key
|
|
65
|
+
|
|
66
|
+
site_config {
|
|
67
|
+
application_stack {
|
|
68
|
+
python_version = var.python_version
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
cors {
|
|
72
|
+
allowed_origins = var.cors_allowed_origins
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
app_settings = merge(
|
|
77
|
+
{
|
|
78
|
+
"FUNCTIONS_WORKER_RUNTIME" = "python"
|
|
79
|
+
"APPINSIGHTS_INSTRUMENTATIONKEY" = azurerm_application_insights.function.instrumentation_key
|
|
80
|
+
"ENVIRONMENT" = var.environment
|
|
81
|
+
"PROJECT_NAME" = var.project_name
|
|
82
|
+
},
|
|
83
|
+
var.app_settings,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
identity {
|
|
87
|
+
type = "SystemAssigned"
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
tags = merge(var.tags, {
|
|
91
|
+
Name = local.function_name
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
### MUST EDIT THIS ###
|
|
95
|
+
# Deploy your function code using:
|
|
96
|
+
# az functionapp deployment source config-zip -g <rg> -n <name> --src <zip>
|
|
97
|
+
# Or configure CI/CD deployment.
|
|
98
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
2
|
+
# LAMBDA MODULE (Azure Functions) — Outputs
|
|
3
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
output "function_app_name" {
|
|
6
|
+
description = "Name of the Function App"
|
|
7
|
+
value = azurerm_linux_function_app.main.name
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
output "function_app_id" {
|
|
11
|
+
description = "ID of the Function App"
|
|
12
|
+
value = azurerm_linux_function_app.main.id
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
output "default_hostname" {
|
|
16
|
+
description = "Default hostname of the Function App"
|
|
17
|
+
value = azurerm_linux_function_app.main.default_hostname
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
output "principal_id" {
|
|
21
|
+
description = "Managed Identity principal ID"
|
|
22
|
+
value = azurerm_linux_function_app.main.identity[0].principal_id
|
|
23
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
2
|
+
# LAMBDA MODULE (Azure Functions) — Variables
|
|
3
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
variable "project_name" {
|
|
6
|
+
description = "Name of the project"
|
|
7
|
+
type = string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
variable "environment" {
|
|
11
|
+
description = "Deployment environment"
|
|
12
|
+
type = string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
variable "location" {
|
|
16
|
+
description = "Azure region"
|
|
17
|
+
type = string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
variable "resource_group_name" {
|
|
21
|
+
description = "Name of the resource group"
|
|
22
|
+
type = string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
variable "sku_name" {
|
|
26
|
+
description = "App Service Plan SKU (Y1 = Consumption, EP1 = Premium)"
|
|
27
|
+
type = string
|
|
28
|
+
default = "Y1"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
variable "python_version" {
|
|
32
|
+
description = "Python version for the function runtime"
|
|
33
|
+
type = string
|
|
34
|
+
default = "3.11"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
variable "app_settings" {
|
|
38
|
+
description = "Additional app settings"
|
|
39
|
+
type = map(string)
|
|
40
|
+
default = {}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
variable "cors_allowed_origins" {
|
|
44
|
+
description = "CORS allowed origins"
|
|
45
|
+
type = list(string)
|
|
46
|
+
default = ["*"]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
variable "tags" {
|
|
50
|
+
description = "Common resource tags"
|
|
51
|
+
type = map(string)
|
|
52
|
+
default = {}
|
|
53
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# MESSAGING MODULE — Service Bus Queue (Azure)
|
|
2
|
+
# Generated by tf-starter
|
|
3
|
+
|
|
4
|
+
locals {
|
|
5
|
+
name_prefix = "${var.project_name}-${var.environment}"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
resource "azurerm_servicebus_namespace" "main" {
|
|
9
|
+
name = "${local.name_prefix}-sb"
|
|
10
|
+
resource_group_name = var.resource_group_name
|
|
11
|
+
location = var.location
|
|
12
|
+
sku = "Standard"
|
|
13
|
+
tags = var.tags
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
resource "azurerm_servicebus_queue" "main" {
|
|
17
|
+
name = "${local.name_prefix}-queue"
|
|
18
|
+
namespace_id = azurerm_servicebus_namespace.main.id
|
|
19
|
+
|
|
20
|
+
max_delivery_count = 10
|
|
21
|
+
dead_lettering_on_message_expiration = true
|
|
22
|
+
default_message_ttl = "P4D"
|
|
23
|
+
lock_duration = "PT30S"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
resource "azurerm_servicebus_queue" "dead_letter" {
|
|
27
|
+
name = "${local.name_prefix}-dlq"
|
|
28
|
+
namespace_id = azurerm_servicebus_namespace.main.id
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# MESSAGING MODULE — Outputs (Azure)
|
|
2
|
+
|
|
3
|
+
output "queue_id" {
|
|
4
|
+
value = azurerm_servicebus_queue.main.id
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
output "namespace_id" {
|
|
8
|
+
value = azurerm_servicebus_namespace.main.id
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
output "namespace_connection_string" {
|
|
12
|
+
value = azurerm_servicebus_namespace.main.default_primary_connection_string
|
|
13
|
+
sensitive = true
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# MESSAGING 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 "tags" {
|
|
9
|
+
type = map(string)
|
|
10
|
+
default = {}
|
|
11
|
+
}
|