-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.tf
More file actions
563 lines (482 loc) · 19.1 KB
/
variables.tf
File metadata and controls
563 lines (482 loc) · 19.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
################################################################################
# modules/reference-stack: variables
#
# Simplified variable surface for the six deployment profiles. Variables are
# grouped by concern; each group documents which leaf module consumes it.
################################################################################
################################################################################
# Core identity
################################################################################
variable "deployment_name" {
description = <<-EOT
Name of this Poolside deployment. Used as the basis for naming every AWS
resource (EKS cluster, RDS instance, S3 buckets, IAM roles, etc.).
Must be lowercase alphanumeric with optional hyphens.
EOT
type = string
validation {
condition = can(regex("^[a-z0-9]([a-z0-9-]*[a-z0-9])?$", var.deployment_name))
error_message = "deployment_name must be lowercase alphanumeric with optional hyphens, and may not start or end with a hyphen."
}
# AWS caps ALB names at 32 chars. The poolside-values module uses
# `poolside-<deployment_name>` for the alb.ingress.kubernetes.io/
# load-balancer-name annotation, so the prefix consumes 9 chars and
# leaves 23 for deployment_name. Failing at plan time beats failing
# 25 minutes into apply when the LBC rejects the ingress.
validation {
condition = length(var.deployment_name) <= 23
error_message = "deployment_name must be ≤23 characters: it's used as a suffix on the ALB name (`poolside-<deployment_name>`), and AWS caps ALB names at 32 chars."
}
}
variable "region" {
description = "AWS region for all resources."
type = string
}
variable "tags" {
description = "Tags applied to every resource. Merged with automatic managed-by and deployment-name tags."
type = map(string)
default = {}
}
################################################################################
# Deployment profile flags
################################################################################
variable "enable_gpu_node_group" {
description = <<-EOT
Whether to create a GPU node group for local model inference. Set true for
the full profile. When true, the gpu-operator module is
also installed.
EOT
type = bool
default = false
}
variable "enable_cognito" {
description = <<-EOT
Whether to create an AWS Cognito user pool for authentication. Default
false — most deployments bring their own OIDC provider. When true,
var.public_hostname must be set.
EOT
type = bool
default = false
}
################################################################################
# Network
################################################################################
variable "vpc_cidr" {
description = "CIDR block for the VPC. Default /21 supports up to 4 AZs with the reference architecture subnet layout."
type = string
default = "10.0.0.0/21"
}
variable "availability_zones" {
description = "AZ letters to use (e.g. [\"a\", \"b\"]). 2-4 zones supported."
type = list(string)
default = ["a", "b"]
}
variable "single_nat_gateway" {
description = "Use a single shared NAT gateway instead of one per AZ. Saves cost but removes AZ-level NAT redundancy."
type = bool
default = false
}
################################################################################
# EKS cluster
################################################################################
variable "kubernetes_version" {
description = "Kubernetes minor version for the EKS cluster (e.g. \"1.32\")."
type = string
default = "1.32"
}
variable "eks_support_type" {
description = "EKS support type: \"STANDARD\" (default, no extra cost) or \"EXTENDED\" (paid, extends support window)."
type = string
default = "STANDARD"
}
variable "cluster_endpoint_public_access" {
description = "Whether the EKS public API endpoint is enabled."
type = bool
default = true
}
variable "cluster_endpoint_public_access_cidrs" {
description = "CIDR blocks allowed to reach the EKS public API endpoint. No default — must be explicitly set."
type = list(string)
}
variable "admin_principal_arns" {
description = "AWS principal ARNs that get cluster-admin access via EKS Access Entries."
type = list(string)
}
variable "allow_locked_out_cluster" {
description = "When false (default), validates that the running principal is in admin_principal_arns to prevent lockout."
type = bool
default = false
}
################################################################################
# CPU node group
################################################################################
variable "cpu_instance_type" {
description = "EC2 instance type for the CPU node group."
type = string
default = "m5.4xlarge"
}
variable "cpu_min_size" {
description = "Minimum number of CPU nodes."
type = number
default = 1
}
variable "cpu_max_size" {
description = "Maximum number of CPU nodes."
type = number
default = 10
}
variable "cpu_desired_size" {
description = "Initial desired number of CPU nodes."
type = number
default = 3
}
variable "cpu_ebs_volume_size_gib" {
description = "Root EBS volume size (GiB) for CPU nodes."
type = number
default = 200
}
variable "cpu_ami_type" {
description = <<-EOT
EKS-managed AMI type for the CPU node group. Default
`AL2023_x86_64_STANDARD` is the AL2023 EKS-optimized image. Other valid
values include `AL2023_ARM_64_STANDARD` (Graviton),
`BOTTLEROCKET_x86_64`, `BOTTLEROCKET_ARM_64`. If you set
`cpu_custom_ami_id`, this must match a value compatible with your AMI.
EOT
type = string
default = "AL2023_x86_64_STANDARD"
}
variable "cpu_ami_release_version" {
description = <<-EOT
Specific AL2023 EKS-optimized AMI release version to pin for the CPU
node group (e.g. "1.32.0-20251120"). Default null = AWS-managed latest
for the cluster's Kubernetes version. Pin to avoid surprise AMI
rotations during operations windows.
EOT
type = string
default = null
}
variable "cpu_custom_ami_id" {
description = <<-EOT
Bring-your-own AMI ID for the CPU node group. When set, AWS-managed
AMI updates are disabled — you own AMI lifecycle, EKS compatibility
(kubelet, containerd, CNI, SSM agent), and any custom-CA injection.
When set, `cpu_custom_user_data` MUST also be set (empty string is
allowed if your AMI self-bootstraps).
EOT
type = string
default = null
}
variable "cpu_custom_user_data" {
description = <<-EOT
Raw cloud-init user data injected into the CPU node group's launch
template. REQUIRED when `cpu_custom_ami_id` is set; ignored otherwise.
Pass empty string "" if your custom AMI self-bootstraps (rare). When
`cpu_custom_ami_id` is null, the AWS-managed AMI's nodeadm bootstrap
is used and this is ignored.
EOT
type = string
default = null
}
################################################################################
# GPU node group (only when enable_gpu_node_group = true)
################################################################################
variable "gpu_instance_type" {
description = "EC2 instance type for the GPU node group."
type = string
default = "p5e.48xlarge"
}
variable "gpu_min_size" {
description = "Minimum number of GPU nodes. Default 0 (scale from zero)."
type = number
default = 0
}
variable "gpu_max_size" {
description = "Maximum number of GPU nodes."
type = number
default = 2
}
variable "gpu_desired_size" {
description = "Initial desired number of GPU nodes."
type = number
default = 0
}
variable "gpu_ebs_volume_size_gib" {
description = "Root EBS volume size (GiB) for GPU nodes."
type = number
default = 200
}
variable "gpu_ami_type" {
description = <<-EOT
EKS-managed AMI type for the GPU node group. Default
`AL2023_x86_64_NVIDIA` is the AL2023 EKS-optimized image with NVIDIA
drivers and container toolkit pre-installed. If you set
`gpu_custom_ami_id`, this must match a value compatible with your AMI.
EOT
type = string
default = "AL2023_x86_64_NVIDIA"
}
variable "gpu_ami_release_version" {
description = <<-EOT
Specific AL2023 NVIDIA EKS-optimized AMI release version to pin for
the GPU node group. Default null = AWS-managed latest for the
cluster's Kubernetes version. Pin to avoid surprise driver-version
changes during operations windows.
EOT
type = string
default = null
}
variable "gpu_custom_ami_id" {
description = <<-EOT
Bring-your-own AMI ID for the GPU node group. CRITICAL: a custom GPU
AMI must include working NVIDIA drivers, nvidia-container-toolkit,
and the runtime setup the device plugin expects. The AL2023 NVIDIA
AMI ships all of this; a barebones custom AMI will boot but pods
will fail to schedule because the GPUs aren't visible to the device
plugin. When set, `gpu_custom_user_data` MUST also be set.
EOT
type = string
default = null
}
variable "gpu_custom_user_data" {
description = <<-EOT
Raw cloud-init user data injected into the GPU node group's launch
template. REQUIRED when `gpu_custom_ami_id` is set; ignored otherwise.
EOT
type = string
default = null
}
variable "gpu_subnet_ids" {
description = <<-EOT
Subnet IDs for the GPU node group. Default null = use all private worker
subnets (spans every AZ). Override to pin GPU nodes to specific AZ(s)
where capacity reservations exist — without this, the node group may
attempt to launch in an AZ that has no CR capacity and fail with
InsufficientInstanceCapacity.
Use the `private_worker_subnet_ids_by_az` output from reference-stack
to select the right subnet(s):
gpu_subnet_ids = [module.stack.private_worker_subnet_ids_by_az["us-east-2b"]]
EOT
type = list(string)
default = null
}
variable "gpu_capacity_reservation_id" {
description = <<-EOT
EC2 capacity reservation ID to target for GPU instances. Optional.
Verify the reservation has available capacity before applying:
aws ec2 describe-capacity-reservations --capacity-reservation-ids <cr-id> \
--query 'CapacityReservations[0].AvailableInstanceCount'
Targeted reservations (InstanceMatchCriteria: targeted) must be explicitly
referenced. Cross-account reservations shared via AWS RAM are supported.
EOT
type = string
default = null
}
variable "gpu_capacity_reservation_resource_group_arn" {
description = <<-EOT
Capacity reservation resource group ARN for GPU instances. Optional.
Alternative to gpu_capacity_reservation_id — use when capacity is
managed via a resource group rather than a specific reservation.
Verify available capacity before applying.
EOT
type = string
default = null
}
variable "gpu_use_capacity_block" {
description = "Enable EC2 Capacity Block for ML on the GPU node group."
type = bool
default = false
}
################################################################################
# Database (RDS PostgreSQL)
################################################################################
variable "database_instance_class" {
description = "RDS instance class for the PostgreSQL database."
type = string
default = "db.m7g.xlarge"
}
variable "database_multi_az" {
description = "Enable RDS multi-AZ with synchronous standby."
type = bool
default = true
}
variable "database_allocated_storage_gib" {
description = "Initial allocated storage (GiB) for the RDS instance."
type = number
default = 64
}
variable "database_max_allocated_storage_gib" {
description = "Maximum storage (GiB) for RDS storage auto-scaling."
type = number
default = 256
}
variable "database_deletion_protection" {
description = "Enable RDS deletion protection. Set false for POC teardown."
type = bool
default = true
}
################################################################################
# Cognito (only when enable_cognito = true)
################################################################################
variable "public_hostname" {
description = <<-EOT
Public DNS hostname for the Poolside deployment (e.g.
"poolside.example.com"). Required.
The reference architecture terminates TLS at the ALB and is transitively coupled
to a hostname: an ACM cert is bound to a hostname, and the ALB
listener needs a cert. Cognito (when enabled) also uses this for
callback/logout URLs. Must be a syntactically valid lowercase DNS
hostname (dots + hyphens; no uppercase, underscores, or leading/
trailing hyphens).
EOT
type = string
nullable = false
validation {
condition = can(regex("^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$", var.public_hostname))
error_message = "public_hostname must be a valid lowercase DNS hostname with at least one dot (e.g. \"poolside.example.com\"). Uppercase, underscores, and leading/trailing hyphens are not permitted."
}
}
################################################################################
# IAM
################################################################################
variable "iam_name_prefix" {
description = <<-EOT
Prefix prepended to every IAM role and policy name. For regulated
environments (PubSec) where SCPs require specific naming. Empty string
means no prefix.
EOT
type = string
default = ""
}
variable "permissions_boundary_arn" {
description = <<-EOT
ARN of an IAM permissions boundary policy to attach to every IAM role the
stack creates (node group roles, IRSA roles, and the EKS cluster role).
Required by some regulated environments where SCPs mandate a boundary on
all new roles. When empty (default), no boundary is attached.
EOT
type = string
default = ""
}
################################################################################
# TLS / Custom CA
################################################################################
variable "custom_ca_bundle_pem" {
description = <<-EOT
PEM-encoded custom CA certificate chain to trust. When non-empty, a
ConfigMap is created in the poolside namespace and mounted into all
Poolside pods at /etc/ssl/certs/custom-ca-bundle.crt. Use this when
the deployment environment has internal CAs (e.g. corporate proxy,
private git servers, self-signed MCP server certs).
Provide the full PEM chain (root + any intermediates) as a single
string. Example:
custom_ca_bundle_pem = file("path/to/ca-chain.pem")
EOT
type = string
default = ""
}
################################################################################
# S3 / ECR lifecycle
################################################################################
variable "s3_force_destroy_buckets" {
description = "Allow terraform destroy to delete S3 buckets that contain objects. Use with caution."
type = bool
default = false
}
variable "ecr_force_destroy_repositories" {
description = "Allow terraform destroy to delete ECR repositories that contain images."
type = bool
default = false
}
variable "containers_dir" {
description = <<-EOT
Absolute path to the `containers/` directory of an extracted Poolside
Helm bundle. The ecr submodule scans this directory for
`<repo>__<tag>__<arch>.tar` tarballs, creates one ECR repository per
unique <repo>, and pushes each tarball to its corresponding repo at
the parsed tag. The bundle is expected to live outside this
repository — there is no default. Example:
containers_dir = "/home/ops/poolside-helm-<version>/containers"
EOT
type = string
validation {
condition = length(var.containers_dir) > 0
error_message = "containers_dir must not be empty."
}
}
variable "ecr_image_name_overrides" {
description = <<-EOT
Map of bundle-parsed image name -> ECR repo name (sans deployment
prefix). Use this when a tarball's filename-derived name needs to be
remapped for the chart (e.g. `{ forge_api = "forge-api" }`).
EOT
type = map(string)
default = {}
}
variable "ecr_force_push_cookie" {
description = "Opaque string passed to the ecr submodule; bump to force re-push of every image on the next apply."
type = string
default = ""
}
################################################################################
# Model checkpoints
#
# Reference-stack owns the infra side of model-checkpoint handling:
# whether to create a <deployment>-models S3 bucket, and whether to run
# this reference architecture's streaming uploader against a local directory of tarballs.
#
# The inference-chart-values side lives in modules/poolside-values. The
# operator wires reference-stack → poolside-values → helm-wrapper in
# their root.
################################################################################
variable "enable_model_s3_upload" {
description = <<-EOT
When true (default — the happy path for full-profile deployments),
Terraform creates a <deployment>-models S3 bucket AND scans
var.checkpoints_dir for *.tar files, uploading each tarball's
contents via the model-checkpoints module.
When false, no bucket is created and no upload runs. The operator
pre-positions checkpoints elsewhere and supplies
var.external_models_bucket so the inference pod's IRSA role can
read from their bucket.
Set to false for platform-only deployments that don't run inference.
EOT
type = bool
default = true
}
variable "checkpoints_dir" {
description = <<-EOT
Absolute path to a local directory of `*.tar` model checkpoint
archives. Required when enable_model_s3_upload=true; ignored when
false.
Each `*.tar` becomes an S3 upload keyed at
`s3://<bucket>/models/checkpoints/<tarball_stem>/<file>`.
EOT
type = string
default = ""
}
variable "use_s3_transfer_acceleration" {
description = <<-EOT
When true, enables S3 Transfer Acceleration on the models bucket
AND tells the model-checkpoints uploader to use the accelerated
endpoint. Routes uploads through CloudFront edge → AWS backbone,
speeding up uploads from operators geographically distant from the
bucket region (e.g. Europe ↔ us-east-2; typical 2-5x speedup).
Costs ~$0.04/GB extra. Opt-in to avoid surprise charges. Has no
effect when enable_model_s3_upload = false (no bucket, no upload).
EOT
type = bool
default = false
}
variable "external_models_bucket" {
description = <<-EOT
Name of an externally-managed S3 bucket containing pre-positioned
model checkpoints. Used ONLY when enable_model_s3_upload=false.
When set, the inference pod's IRSA role is scoped to grant
`s3:GetObject` + `s3:ListBucket` on this bucket.
Cross-account buckets are NOT supported — the bucket must be
in the same AWS account as the reference architecture deployment.
EOT
type = string
default = ""
}