Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

update variable min/max to single variable #49

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions examples/nomad-consul-separate-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,9 @@ module "nomad_servers" {
source = "../../modules/nomad-cluster"

cluster_name = "${var.nomad_cluster_name}-server"
cluster_size = var.num_nomad_servers
instance_type = "t2.micro"

# You should typically use a fixed size of 3 or 5 for your Nomad server cluster
min_size = var.num_nomad_servers
max_size = var.num_nomad_servers
desired_capacity = var.num_nomad_servers

ami_id = var.ami_id == null ? data.aws_ami.nomad_consul.image_id : var.ami_id
user_data = data.template_file.user_data_nomad_server.rendered

Expand Down
7 changes: 4 additions & 3 deletions modules/nomad-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ resource "aws_autoscaling_group" "autoscaling_group" {
availability_zones = var.availability_zones
vpc_zone_identifier = var.subnet_ids

min_size = var.min_size
max_size = var.max_size
desired_capacity = var.desired_capacity
min_size = var.cluster_size
max_size = var.cluster_size
desired_capacity = var.cluster_size
termination_policies = [var.termination_policies]

health_check_type = var.health_check_type
Expand Down Expand Up @@ -58,6 +58,7 @@ resource "aws_launch_configuration" "launch_configuration" {
image_id = var.ami_id
instance_type = var.instance_type
user_data = var.user_data
spot_price = var.spot_price

iam_instance_profile = aws_iam_instance_profile.instance_profile.name
key_name = var.ssh_key_name
Expand Down
21 changes: 9 additions & 12 deletions modules/nomad-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,10 @@ variable "user_data" {
type = string
}

variable "min_size" {
description = "The minimum number of nodes to have in the cluster. If you're using this to run Nomad servers, we strongly recommend setting this to 3 or 5."
type = number
}

variable "max_size" {
description = "The maximum number of nodes to have in the cluster. If you're using this to run Nomad servers, we strongly recommend setting this to 3 or 5."
type = number
}

variable "desired_capacity" {
description = "The desired number of nodes to have in the cluster. If you're using this to run Nomad servers, we strongly recommend setting this to 3 or 5."
variable "cluster_size" {
description = "The number of nodes to have in the Nomad cluster. We strongly recommended that you use either 3 or 5."
type = number
default = 3
}

# ---------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -107,6 +98,12 @@ variable "associate_public_ip_address" {
default = false
}

variable "spot_price" {
description = "The maximum hourly price to pay for EC2 Spot Instances."
type = number
default = null
}

variable "tenancy" {
description = "The tenancy of the instance. Must be one of: default or dedicated."
type = string
Expand Down