diff --git a/terraform/aws/nodes.tf b/terraform/aws/nodes.tf index d4f0806..11d668f 100644 --- a/terraform/aws/nodes.tf +++ b/terraform/aws/nodes.tf @@ -38,6 +38,8 @@ resource "aws_eks_node_group" "core_nodes" { instance_types = [var.instance_type] + capacity_type = var.capacity_type + scaling_config { desired_size = 1 max_size = var.max_instances @@ -59,4 +61,4 @@ resource "aws_eks_node_group" "core_nodes" { aws_iam_role_policy_attachment.node_worker_cni_policy_attachment, aws_iam_role_policy_attachment.node_worker_ecr_policy_attachment ] -} \ No newline at end of file +} diff --git a/terraform/aws/variables.tf b/terraform/aws/variables.tf index 6501e88..2852c62 100644 --- a/terraform/aws/variables.tf +++ b/terraform/aws/variables.tf @@ -19,6 +19,18 @@ variable "instance_type" { EOT } +variable "capacity_type" { + default = "ON_DEMAND" + description = <<-EOT + Whether to use ON_DEMAND or SPOT instances. + EOT + + validation { + condition = contains(["ON_DEMAND", "SPOT"], var.capacity_type) + error_message = "The capcity_type value must be ON_DEMAND or SPOT." + } +} + variable "max_instances" { default = 10 type = number