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,210 @@
|
|
|
1
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
2
|
+
# ROOT MAIN CONFIGURATION
|
|
3
|
+
# Project: {{ project_name }}
|
|
4
|
+
# Provider: GCP
|
|
5
|
+
# Generated by tf-starter
|
|
6
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
locals {
|
|
9
|
+
project_name = "{{ project_name }}"
|
|
10
|
+
region = var.region
|
|
11
|
+
environment = var.environment
|
|
12
|
+
|
|
13
|
+
common_labels = {
|
|
14
|
+
project = local.project_name
|
|
15
|
+
environment = local.environment
|
|
16
|
+
managed-by = "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
|
+
region = local.region
|
|
31
|
+
project_id = var.project_id
|
|
32
|
+
|
|
33
|
+
labels = local.common_labels
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
{% if "compute" in services %}
|
|
37
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
38
|
+
# COMPUTE MODULE
|
|
39
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
module "compute" {
|
|
42
|
+
source = "./modules/compute"
|
|
43
|
+
|
|
44
|
+
project_name = local.project_name
|
|
45
|
+
environment = local.environment
|
|
46
|
+
project_id = var.project_id
|
|
47
|
+
region = local.region
|
|
48
|
+
|
|
49
|
+
network_self_link = module.network.network_self_link
|
|
50
|
+
subnet_self_link = module.network.private_subnet_self_link
|
|
51
|
+
|
|
52
|
+
machine_type = var.machine_type
|
|
53
|
+
min_replicas = var.mig_min_replicas
|
|
54
|
+
max_replicas = var.mig_max_replicas
|
|
55
|
+
target_size = var.mig_target_size
|
|
56
|
+
|
|
57
|
+
labels = local.common_labels
|
|
58
|
+
}
|
|
59
|
+
{% endif %}
|
|
60
|
+
|
|
61
|
+
{% if "lambda" in services %}
|
|
62
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
63
|
+
# LAMBDA MODULE (Cloud Functions)
|
|
64
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
module "lambda" {
|
|
67
|
+
source = "./modules/lambda"
|
|
68
|
+
|
|
69
|
+
project_name = local.project_name
|
|
70
|
+
environment = local.environment
|
|
71
|
+
project_id = var.project_id
|
|
72
|
+
region = local.region
|
|
73
|
+
|
|
74
|
+
function_name = var.function_name
|
|
75
|
+
runtime = var.function_runtime
|
|
76
|
+
entry_point = var.function_entry_point
|
|
77
|
+
timeout = var.function_timeout
|
|
78
|
+
memory = var.function_memory
|
|
79
|
+
max_instances = var.function_max_instances
|
|
80
|
+
environment_variables = var.function_environment_variables
|
|
81
|
+
|
|
82
|
+
labels = local.common_labels
|
|
83
|
+
}
|
|
84
|
+
{% endif %}
|
|
85
|
+
|
|
86
|
+
{% if "apigateway" in services %}
|
|
87
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
88
|
+
# API GATEWAY MODULE
|
|
89
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
90
|
+
|
|
91
|
+
module "apigateway" {
|
|
92
|
+
source = "./modules/apigateway"
|
|
93
|
+
|
|
94
|
+
project_name = local.project_name
|
|
95
|
+
environment = local.environment
|
|
96
|
+
project_id = var.project_id
|
|
97
|
+
region = local.region
|
|
98
|
+
|
|
99
|
+
function_uri = module.lambda.function_uri
|
|
100
|
+
|
|
101
|
+
labels = local.common_labels
|
|
102
|
+
}
|
|
103
|
+
{% endif %}
|
|
104
|
+
|
|
105
|
+
{% if "database" in services %}
|
|
106
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
107
|
+
# DATABASE MODULE
|
|
108
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
109
|
+
|
|
110
|
+
module "database" {
|
|
111
|
+
source = "./modules/database"
|
|
112
|
+
|
|
113
|
+
project_name = local.project_name
|
|
114
|
+
environment = local.environment
|
|
115
|
+
project_id = var.project_id
|
|
116
|
+
region = local.region
|
|
117
|
+
|
|
118
|
+
network_self_link = module.network.network_self_link
|
|
119
|
+
private_ip_range_name = module.network.private_ip_range_name
|
|
120
|
+
|
|
121
|
+
db_tier = var.db_tier
|
|
122
|
+
db_name = var.db_name
|
|
123
|
+
db_user = var.db_user
|
|
124
|
+
db_ha = var.environment == "prod" ? true : false
|
|
125
|
+
|
|
126
|
+
labels = local.common_labels
|
|
127
|
+
}
|
|
128
|
+
{% endif %}
|
|
129
|
+
|
|
130
|
+
{% if "kubernetes" in services %}
|
|
131
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
132
|
+
# KUBERNETES MODULE (GKE)
|
|
133
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
134
|
+
|
|
135
|
+
module "kubernetes" {
|
|
136
|
+
source = "./modules/kubernetes"
|
|
137
|
+
|
|
138
|
+
project_name = local.project_name
|
|
139
|
+
environment = local.environment
|
|
140
|
+
project_id = var.project_id
|
|
141
|
+
region = local.region
|
|
142
|
+
|
|
143
|
+
network_self_link = module.network.network_self_link
|
|
144
|
+
subnet_self_link = module.network.private_subnet_self_link
|
|
145
|
+
|
|
146
|
+
cluster_version = var.gke_cluster_version
|
|
147
|
+
node_machine_type = var.gke_node_machine_type
|
|
148
|
+
node_count = var.gke_node_count
|
|
149
|
+
node_min_count = var.gke_node_min_count
|
|
150
|
+
node_max_count = var.gke_node_max_count
|
|
151
|
+
|
|
152
|
+
labels = local.common_labels
|
|
153
|
+
}
|
|
154
|
+
{% endif %}
|
|
155
|
+
|
|
156
|
+
{% if "monitoring" in services %}
|
|
157
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
158
|
+
# MONITORING MODULE
|
|
159
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
160
|
+
|
|
161
|
+
module "monitoring" {
|
|
162
|
+
source = "./modules/monitoring"
|
|
163
|
+
|
|
164
|
+
project_name = local.project_name
|
|
165
|
+
environment = local.environment
|
|
166
|
+
project_id = var.project_id
|
|
167
|
+
|
|
168
|
+
notification_email = var.notification_email
|
|
169
|
+
|
|
170
|
+
labels = local.common_labels
|
|
171
|
+
}
|
|
172
|
+
{% endif %}
|
|
173
|
+
|
|
174
|
+
{% if "messaging" in services %}
|
|
175
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
176
|
+
# MESSAGING MODULE (Pub/Sub)
|
|
177
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
module "messaging" {
|
|
180
|
+
source = "./modules/messaging"
|
|
181
|
+
|
|
182
|
+
project_name = local.project_name
|
|
183
|
+
environment = local.environment
|
|
184
|
+
project_id = var.project_id
|
|
185
|
+
|
|
186
|
+
message_retention_duration = var.pubsub_message_retention
|
|
187
|
+
ack_deadline_seconds = var.pubsub_ack_deadline
|
|
188
|
+
|
|
189
|
+
labels = local.common_labels
|
|
190
|
+
}
|
|
191
|
+
{% endif %}
|
|
192
|
+
|
|
193
|
+
{% if "storage" in services %}
|
|
194
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
195
|
+
# STORAGE MODULE (GCS)
|
|
196
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
197
|
+
|
|
198
|
+
module "storage" {
|
|
199
|
+
source = "./modules/storage"
|
|
200
|
+
|
|
201
|
+
project_name = local.project_name
|
|
202
|
+
environment = local.environment
|
|
203
|
+
project_id = var.project_id
|
|
204
|
+
region = local.region
|
|
205
|
+
|
|
206
|
+
enable_versioning = var.gcs_enable_versioning
|
|
207
|
+
|
|
208
|
+
labels = local.common_labels
|
|
209
|
+
}
|
|
210
|
+
{% endif %}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
2
|
+
# ROOT OUTPUTS — GCP
|
|
3
|
+
# Generated by tf-starter
|
|
4
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
output "network_self_link" {
|
|
7
|
+
description = "Self-link of the VPC network"
|
|
8
|
+
value = module.network.network_self_link
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
{% if "compute" in services %}
|
|
12
|
+
output "load_balancer_ip" {
|
|
13
|
+
description = "External IP of the load balancer"
|
|
14
|
+
value = module.compute.load_balancer_ip
|
|
15
|
+
}
|
|
16
|
+
{% endif %}
|
|
17
|
+
|
|
18
|
+
{% if "database" in services %}
|
|
19
|
+
output "db_connection_name" {
|
|
20
|
+
description = "Cloud SQL connection name"
|
|
21
|
+
value = module.database.connection_name
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
output "db_ip_address" {
|
|
25
|
+
description = "Cloud SQL private IP"
|
|
26
|
+
value = module.database.private_ip
|
|
27
|
+
}
|
|
28
|
+
{% endif %}
|
|
29
|
+
|
|
30
|
+
{% if "kubernetes" in services %}
|
|
31
|
+
output "gke_cluster_endpoint" {
|
|
32
|
+
description = "GKE cluster endpoint"
|
|
33
|
+
value = module.kubernetes.cluster_endpoint
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
output "gke_cluster_name" {
|
|
37
|
+
description = "GKE cluster name"
|
|
38
|
+
value = module.kubernetes.cluster_name
|
|
39
|
+
}
|
|
40
|
+
{% endif %}
|
|
41
|
+
|
|
42
|
+
{% if "monitoring" in services %}
|
|
43
|
+
output "notification_channel_id" {
|
|
44
|
+
description = "Monitoring notification channel ID"
|
|
45
|
+
value = module.monitoring.notification_channel_id
|
|
46
|
+
}
|
|
47
|
+
{% endif %}
|
|
48
|
+
|
|
49
|
+
{% if "messaging" in services %}
|
|
50
|
+
output "pubsub_topic_id" {
|
|
51
|
+
description = "Pub/Sub topic ID"
|
|
52
|
+
value = module.messaging.topic_id
|
|
53
|
+
}
|
|
54
|
+
{% endif %}
|
|
55
|
+
|
|
56
|
+
{% if "storage" in services %}
|
|
57
|
+
output "gcs_bucket_name" {
|
|
58
|
+
description = "GCS bucket name"
|
|
59
|
+
value = module.storage.bucket_name
|
|
60
|
+
}
|
|
61
|
+
{% endif %}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
2
|
+
# PROVIDER CONFIGURATION — GCP
|
|
3
|
+
# Project: {{ project_name }}
|
|
4
|
+
# Generated by tf-starter
|
|
5
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
provider "google" {
|
|
8
|
+
project = var.project_id
|
|
9
|
+
region = var.region
|
|
10
|
+
|
|
11
|
+
### MUST EDIT THIS ###
|
|
12
|
+
# credentials = file("path/to/service-account-key.json")
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
provider "google-beta" {
|
|
16
|
+
project = var.project_id
|
|
17
|
+
region = var.region
|
|
18
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
2
|
+
# ROOT VARIABLES — GCP
|
|
3
|
+
# Project: {{ project_name }}
|
|
4
|
+
# Generated by tf-starter
|
|
5
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
variable "project_id" {
|
|
8
|
+
description = "GCP project ID"
|
|
9
|
+
type = string
|
|
10
|
+
|
|
11
|
+
### MUST EDIT THIS ###
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
variable "region" {
|
|
15
|
+
description = "GCP region"
|
|
16
|
+
type = string
|
|
17
|
+
default = "{{ region }}"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
variable "environment" {
|
|
21
|
+
description = "Deployment environment"
|
|
22
|
+
type = string
|
|
23
|
+
default = "dev"
|
|
24
|
+
|
|
25
|
+
validation {
|
|
26
|
+
condition = contains({{ environments | tf_list }}, var.environment)
|
|
27
|
+
error_message = "Environment must be one of: {{ environments | join(', ') }}."
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
{% if "compute" in services %}
|
|
32
|
+
variable "machine_type" {
|
|
33
|
+
description = "Machine type for compute instances"
|
|
34
|
+
type = string
|
|
35
|
+
default = "e2-medium"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
variable "mig_min_replicas" {
|
|
39
|
+
description = "Minimum replicas in MIG"
|
|
40
|
+
type = number
|
|
41
|
+
default = 1
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
variable "mig_max_replicas" {
|
|
45
|
+
description = "Maximum replicas in MIG"
|
|
46
|
+
type = number
|
|
47
|
+
default = 4
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
variable "mig_target_size" {
|
|
51
|
+
description = "Target size of MIG"
|
|
52
|
+
type = number
|
|
53
|
+
default = 2
|
|
54
|
+
}
|
|
55
|
+
{% endif %}
|
|
56
|
+
|
|
57
|
+
{% if "database" in services %}
|
|
58
|
+
variable "db_tier" {
|
|
59
|
+
description = "Cloud SQL instance tier"
|
|
60
|
+
type = string
|
|
61
|
+
default = "db-custom-2-7680"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
variable "db_name" {
|
|
65
|
+
description = "Database name"
|
|
66
|
+
type = string
|
|
67
|
+
default = "{{ project_name | replace('-', '_') }}_db"
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
variable "db_user" {
|
|
71
|
+
description = "Database user"
|
|
72
|
+
type = string
|
|
73
|
+
default = "dbadmin"
|
|
74
|
+
sensitive = true
|
|
75
|
+
}
|
|
76
|
+
{% endif %}
|
|
77
|
+
|
|
78
|
+
{% if "kubernetes" in services %}
|
|
79
|
+
variable "gke_cluster_version" {
|
|
80
|
+
description = "GKE cluster version"
|
|
81
|
+
type = string
|
|
82
|
+
default = "latest"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
variable "gke_node_machine_type" {
|
|
86
|
+
description = "Machine type for GKE nodes"
|
|
87
|
+
type = string
|
|
88
|
+
default = "e2-standard-4"
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
variable "gke_node_count" {
|
|
92
|
+
description = "Initial node count"
|
|
93
|
+
type = number
|
|
94
|
+
default = 2
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
variable "gke_node_min_count" {
|
|
98
|
+
description = "Minimum node count"
|
|
99
|
+
type = number
|
|
100
|
+
default = 1
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
variable "gke_node_max_count" {
|
|
104
|
+
description = "Maximum node count"
|
|
105
|
+
type = number
|
|
106
|
+
default = 5
|
|
107
|
+
}
|
|
108
|
+
{% endif %}
|
|
109
|
+
|
|
110
|
+
{% if "monitoring" in services %}
|
|
111
|
+
variable "notification_email" {
|
|
112
|
+
description = "Email for monitoring notifications"
|
|
113
|
+
type = string
|
|
114
|
+
default = ""
|
|
115
|
+
|
|
116
|
+
### MUST EDIT THIS ###
|
|
117
|
+
}
|
|
118
|
+
{% endif %}
|
|
119
|
+
|
|
120
|
+
{% if "messaging" in services %}
|
|
121
|
+
variable "pubsub_message_retention" {
|
|
122
|
+
description = "Pub/Sub message retention duration"
|
|
123
|
+
type = string
|
|
124
|
+
default = "604800s"
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
variable "pubsub_ack_deadline" {
|
|
128
|
+
description = "Pub/Sub acknowledgement deadline in seconds"
|
|
129
|
+
type = number
|
|
130
|
+
default = 20
|
|
131
|
+
}
|
|
132
|
+
{% endif %}
|
|
133
|
+
|
|
134
|
+
{% if "storage" in services %}
|
|
135
|
+
variable "gcs_enable_versioning" {
|
|
136
|
+
description = "Enable GCS bucket versioning"
|
|
137
|
+
type = bool
|
|
138
|
+
default = true
|
|
139
|
+
}
|
|
140
|
+
{% endif %}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
2
|
+
# TERRAFORM AND PROVIDER VERSIONS — GCP
|
|
3
|
+
# Generated by tf-starter
|
|
4
|
+
# ---------------------------------------------------------------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
terraform {
|
|
7
|
+
required_version = ">= 1.6.0"
|
|
8
|
+
|
|
9
|
+
required_providers {
|
|
10
|
+
google = {
|
|
11
|
+
source = "hashicorp/google"
|
|
12
|
+
version = "~> 5.20"
|
|
13
|
+
}
|
|
14
|
+
google-beta = {
|
|
15
|
+
source = "hashicorp/google-beta"
|
|
16
|
+
version = "~> 5.20"
|
|
17
|
+
}
|
|
18
|
+
random = {
|
|
19
|
+
source = "hashicorp/random"
|
|
20
|
+
version = "~> 3.6"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|