From c0d21ef8de73af79fed9577ad6d67a463939b7fa Mon Sep 17 00:00:00 2001 From: Ravi Srivastva Date: Wed, 17 Apr 2024 17:57:14 +0530 Subject: [PATCH] DEV-600 Updated nodegroup configuration to specify MIN/MAX no. of nodes in scale policy --- README.md | 24 ++++-- examples/autoscaling/main.tf | 12 ++- examples/cluster/main.tf | 12 ++- main.tf | 46 ++++++----- red5pro-installer/r5p_create_node_group.sh | 95 ++++++++++++---------- variables.tf | 44 +++++++--- 6 files changed, 140 insertions(+), 93 deletions(-) diff --git a/README.md b/README.md index f9040e6..4da42c1 100644 --- a/README.md +++ b/README.md @@ -231,19 +231,23 @@ module "red5pro" { node_group_create = true # Linux or Mac OS only. true - create new Node group, false - not create new Node group node_group_name = "terraform-node-group" # Node group name # Origin node configuration - node_group_origins = 1 # Number of Origins + node_group_origins_min = 1 # Number of minimum Origins + node_group_origins_max = 20 # Number of maximum Origins node_group_origins_instance_type = "t3.medium" # Instance type for Origins node_group_origins_capacity = 20 # Connections capacity for Origins # Edge node configuration - node_group_edges = 1 # Number of Edges + node_group_edges_min = 1 # Number of minimum Edges + node_group_edges_max = 40 # Number of maximum Edges node_group_edges_instance_type = "t3.medium" # Instance type for Edges node_group_edges_capacity = 200 # Connections capacity for Edges # Transcoder node configuration - node_group_transcoders = 0 # Number of Transcoders + node_group_transcoders_min = 0 # Number of minimum Transcoders + node_group_transcoders_max = 20 # Number of maximum Transcoders node_group_transcoders_instance_type = "t3.medium" # Instance type for Transcoders node_group_transcoders_capacity = 20 # Connections capacity for Transcoders # Relay node configuration - node_group_relays = 0 # Number of Relays + node_group_relays_min = 0 # Number of minimum Relays + node_group_relays_max = 20 # Number of maximum Relays node_group_relays_instance_type = "t3.medium" # Instance type for Relays node_group_relays_capacity = 20 # Connections capacity for Relays @@ -369,19 +373,23 @@ module "red5pro" { node_group_create = true # Linux or Mac OS only. true - create new Node group, false - not create new Node group node_group_name = "terraform-node-group" # Node group name # Origin node configuration - node_group_origins = 1 # Number of Origins + node_group_origins_min = 1 # Number of minimum Origins + node_group_origins_max = 20 # Number of maximum Origins node_group_origins_instance_type = "t3.medium" # Instance type for Origins node_group_origins_capacity = 20 # Connections capacity for Origins # Edge node configuration - node_group_edges = 1 # Number of Edges + node_group_edges_min = 1 # Number of minimum Edges + node_group_edges_max = 40 # Number of maximum Edges node_group_edges_instance_type = "t3.medium" # Instance type for Edges node_group_edges_capacity = 200 # Connections capacity for Edges # Transcoder node configuration - node_group_transcoders = 0 # Number of Transcoders + node_group_transcoders_min = 0 # Number of minimum Transcoders + node_group_transcoders_max = 20 # Number of maximum Transcoders node_group_transcoders_instance_type = "t3.medium" # Instance type for Transcoders node_group_transcoders_capacity = 20 # Connections capacity for Transcoders # Relay node configuration - node_group_relays = 0 # Number of Relays + node_group_relays_min = 0 # Number of minimum Relays + node_group_relays_max = 20 # Number of maximum Relays node_group_relays_instance_type = "t3.medium" # Instance type for Relays node_group_relays_capacity = 20 # Connections capacity for Relays diff --git a/examples/autoscaling/main.tf b/examples/autoscaling/main.tf index e00eb64..12a8002 100644 --- a/examples/autoscaling/main.tf +++ b/examples/autoscaling/main.tf @@ -89,19 +89,23 @@ module "red5pro" { node_group_create = true # Linux or Mac OS only. true - create new Node group, false - not create new Node group node_group_name = "terraform-node-group" # Node group name # Origin node configuration - node_group_origins = 1 # Number of Origins + node_group_origins_min = 1 # Number of minimum Origins + node_group_origins_max = 20 # Number of maximum Origins node_group_origins_instance_type = "t3.medium" # Instance type for Origins node_group_origins_capacity = 20 # Connections capacity for Origins # Edge node configuration - node_group_edges = 1 # Number of Edges + node_group_edges_min = 1 # Number of minimum Edges + node_group_edges_max = 40 # Number of maximum Edges node_group_edges_instance_type = "t3.medium" # Instance type for Edges node_group_edges_capacity = 200 # Connections capacity for Edges # Transcoder node configuration - node_group_transcoders = 0 # Number of Transcoders + node_group_transcoders_min = 0 # Number of minimum Transcoders + node_group_transcoders_max = 20 # Number of maximum Transcoders node_group_transcoders_instance_type = "t3.medium" # Instance type for Transcoders node_group_transcoders_capacity = 20 # Connections capacity for Transcoders # Relay node configuration - node_group_relays = 0 # Number of Relays + node_group_relays_min = 0 # Number of minimum Relays + node_group_relays_max = 20 # Number of maximum Relays node_group_relays_instance_type = "t3.medium" # Instance type for Relays node_group_relays_capacity = 20 # Connections capacity for Relays diff --git a/examples/cluster/main.tf b/examples/cluster/main.tf index 223387c..3797904 100644 --- a/examples/cluster/main.tf +++ b/examples/cluster/main.tf @@ -94,19 +94,23 @@ module "red5pro" { node_group_create = true # Linux or Mac OS only. true - create new Node group, false - not create new Node group node_group_name = "terraform-node-group" # Node group name # Origin node configuration - node_group_origins = 1 # Number of Origins + node_group_origins_min = 1 # Number of minimum Origins + node_group_origins_max = 20 # Number of maximum Origins node_group_origins_instance_type = "t3.medium" # Instance type for Origins node_group_origins_capacity = 20 # Connections capacity for Origins # Edge node configuration - node_group_edges = 1 # Number of Edges + node_group_edges_min = 1 # Number of minimum Edges + node_group_edges_max = 40 # Number of maximum Edges node_group_edges_instance_type = "t3.medium" # Instance type for Edges node_group_edges_capacity = 200 # Connections capacity for Edges # Transcoder node configuration - node_group_transcoders = 0 # Number of Transcoders + node_group_transcoders_min = 0 # Number of minimum Transcoders + node_group_transcoders_max = 20 # Number of maximum Transcoders node_group_transcoders_instance_type = "t3.medium" # Instance type for Transcoders node_group_transcoders_capacity = 20 # Connections capacity for Transcoders # Relay node configuration - node_group_relays = 0 # Number of Relays + node_group_relays_min = 0 # Number of minimum Relays + node_group_relays_max = 20 # Number of maximum Relays node_group_relays_instance_type = "t3.medium" # Instance type for Relays node_group_relays_capacity = 20 # Connections capacity for Relays diff --git a/main.tf b/main.tf index 8843677..54be40a 100644 --- a/main.tf +++ b/main.tf @@ -1201,27 +1201,31 @@ resource "null_resource" "node_group" { when = create command = "bash ${abspath(path.module)}/red5pro-installer/r5p_create_node_group.sh" environment = { - NAME = "${var.name}" - SM_IP = "${local.stream_manager_ip}" - SM_API_KEY = "${var.stream_manager_api_key}" - NODE_GROUP_REGION ="${var.aws_region}" - NODE_GROUP_NAME = "${var.node_group_name}" - ORIGINS = "${var.node_group_origins}" - EDGES = "${var.node_group_edges}" - TRANSCODERS = "${var.node_group_transcoders}" - RELAYS = "${var.node_group_relays}" - ORIGIN_INSTANCE_TYPE = "${var.node_group_origins_instance_type}" - EDGE_INSTANCE_TYPE = "${var.node_group_edges_instance_type}" - TRANSCODER_INSTANCE_TYPE = "${var.node_group_transcoders_instance_type}" - RELAY_INSTANCE_TYPE = "${var.node_group_relays_instance_type}" - ORIGIN_CAPACITY = "${var.node_group_origins_capacity}" - EDGE_CAPACITY = "${var.node_group_edges_capacity}" - TRANSCODER_CAPACITY = "${var.node_group_transcoders_capacity}" - RELAY_CAPACITY = "${var.node_group_relays_capacity}" - ORIGIN_IMAGE_NAME = "${try(aws_ami_from_instance.red5pro_node_origin_image[0].name, null)}" - EDGE_IMAGE_NAME = "${try(aws_ami_from_instance.red5pro_node_edge_image[0].name, null)}" - TRANSCODER_IMAGE_NAME = "${try(aws_ami_from_instance.red5pro_node_transcoder_image[0].name, null)}" - RELAY_IMAGE_NAME = "${try(aws_ami_from_instance.red5pro_node_relay_image[0].name, null)}" + NAME = "${var.name}" + SM_IP = "${local.stream_manager_ip}" + SM_API_KEY = "${var.stream_manager_api_key}" + NODE_GROUP_REGION ="${var.aws_region}" + NODE_GROUP_NAME = "${var.node_group_name}" + ORIGINS_MIN = "${var.node_group_origins_min}" + EDGES_MIN = "${var.node_group_edges_min}" + TRANSCODERS_MIN = "${var.node_group_transcoders_min}" + RELAYS_MIN = "${var.node_group_relays_min}" + ORIGINS_MAX = "${var.node_group_origins_max}" + EDGES_MAX = "${var.node_group_edges_max}" + TRANSCODERS_MAX = "${var.node_group_transcoders_max}" + RELAYS_MAX = "${var.node_group_relays_max}" + ORIGIN_INSTANCE_TYPE = "${var.node_group_origins_instance_type}" + EDGE_INSTANCE_TYPE = "${var.node_group_edges_instance_type}" + TRANSCODER_INSTANCE_TYPE = "${var.node_group_transcoders_instance_type}" + RELAY_INSTANCE_TYPE = "${var.node_group_relays_instance_type}" + ORIGIN_CAPACITY = "${var.node_group_origins_capacity}" + EDGE_CAPACITY = "${var.node_group_edges_capacity}" + TRANSCODER_CAPACITY = "${var.node_group_transcoders_capacity}" + RELAY_CAPACITY = "${var.node_group_relays_capacity}" + ORIGIN_IMAGE_NAME = "${try(aws_ami_from_instance.red5pro_node_origin_image[0].name, null)}" + EDGE_IMAGE_NAME = "${try(aws_ami_from_instance.red5pro_node_edge_image[0].name, null)}" + TRANSCODER_IMAGE_NAME = "${try(aws_ami_from_instance.red5pro_node_transcoder_image[0].name, null)}" + RELAY_IMAGE_NAME = "${try(aws_ami_from_instance.red5pro_node_relay_image[0].name, null)}" } } provisioner "local-exec" { diff --git a/red5pro-installer/r5p_create_node_group.sh b/red5pro-installer/r5p_create_node_group.sh index 9a0ce26..8c72bd8 100755 --- a/red5pro-installer/r5p_create_node_group.sh +++ b/red5pro-installer/r5p_create_node_group.sh @@ -7,15 +7,20 @@ # NODE_GROUP_NAME="terra-node-group" -# ORIGINS=1 -# EDGES=1 -# TRANSCODERS=1 -# RELAYS=1 +# ORIGINS_MIN=1 +# EDGES_MIN=1 +# TRANSCODERS_MIN=1 +# RELAYS_MIN=1 -# ORIGIN_INSTANCE_TYPE="c5.large" -# EDGE_INSTANCE_TYPE="c5.large" -# TRANSCODER_INSTANCE_TYPE="c5.large" -# RELAY_INSTANCE_TYPE="c5.large" +# ORIGINS_MAX=1 +# EDGES_MAX=1 +# TRANSCODERS_MAX=1 +# RELAYS_MAX=1 + +# ORIGIN_INSTANCE_TYPE="c-4" +# EDGE_INSTANCE_TYPE="c-4" +# TRANSCODER_INSTANCE_TYPE="c-4" +# RELAY_INSTANCE_TYPE="c-4" # ORIGIN_CAPACITY="30" # EDGE_CAPACITY="300" @@ -81,11 +86,11 @@ prepare_json_templates(){ launch_config_oet='{"launchconfig":{"name":"'${launch_config_name}'","description":"Launch config Origin,Edge,Transcoder","image":"'$ORIGIN_IMAGE_NAME'","version":"0.0.3","targets":{"target":[{"role":"origin","instanceType":"'$ORIGIN_INSTANCE_TYPE'","connectionCapacity":"'$ORIGIN_CAPACITY'"},{"role":"edge","instanceType":"'$EDGE_INSTANCE_TYPE'","connectionCapacity":"'$EDGE_CAPACITY'","image":"'$EDGE_IMAGE_NAME'"},{"role":"transcoder","instanceType":"'$TRANSCODER_INSTANCE_TYPE'","connectionCapacity":"'$TRANSCODER_CAPACITY'","image":"'$TRANSCODER_IMAGE_NAME'"}]},"properties":{"property":[{"name":"property-name","value":"property-value"}]},"metadata":{"meta":[{"key":"Name","value":"'${nodes_name}'"}]}}}' launch_config_oetr='{"launchconfig":{"name":"'${launch_config_name}'","description":"Launch config Origin,Edge,Transcoder,Relay","image":"'$ORIGIN_IMAGE_NAME'","version":"0.0.3","targets":{"target":[{"role":"origin","instanceType":"'$ORIGIN_INSTANCE_TYPE'","connectionCapacity":"'$ORIGIN_CAPACITY'"},{"role":"edge","instanceType":"'$EDGE_INSTANCE_TYPE'","connectionCapacity":"'$EDGE_CAPACITY'","image":"'$EDGE_IMAGE_NAME'"},{"role":"relay","instanceType":"'$RELAY_INSTANCE_TYPE'","connectionCapacity":"'$RELAY_CAPACITY'","image":"'$RELAY_IMAGE_NAME'"},{"role":"transcoder","instanceType":"'$TRANSCODER_INSTANCE_TYPE'","connectionCapacity":"'$TRANSCODER_CAPACITY'","image":"'$TRANSCODER_IMAGE_NAME'"}]},"properties":{"property":[{"name":"property-name","value":"property-value"}]},"metadata":{"meta":[{"key":"Name","value":"'${nodes_name}'"}]}}}' - scale_policy_o='{"policy":{"name":"'${scale_policy_name}'","description":"Terraform Scale policy Origin","type":"com.red5pro.services.autoscaling.model.ScalePolicyMaster","version": "0.0.3","targets":{"region":[{"name":"default","target":[{"role":"origin","maxLimit":40.0,"scaleAdjustment":1.0,"minLimit":'$ORIGINS'.0}]}]}}}' - scale_policy_oe='{"policy":{"name":"'${scale_policy_name}'","description":"Terraform Scale policy Origin, Edge","type":"com.red5pro.services.autoscaling.model.ScalePolicyMaster","version": "0.0.3","targets":{"region":[{"name":"default","target":[{"role":"edge","maxLimit":80.0,"scaleAdjustment":1.0,"minLimit":'$EDGES'.0},{"role":"origin","maxLimit":40.0,"scaleAdjustment":1.0,"minLimit":'$ORIGINS'.0}]}]}}}' - scale_policy_oer='{"policy":{"name":"'${scale_policy_name}'","description":"Terraform Scale policy Origin, Edge, Relay","type":"com.red5pro.services.autoscaling.model.ScalePolicyMaster","version": "0.0.3","targets":{"region":[{"name":"default","target":[{"role":"edge","maxLimit":80.0,"scaleAdjustment":1.0,"minLimit":'$EDGES'.0},{"role":"origin","maxLimit":40.0,"scaleAdjustment":1.0,"minLimit":'$ORIGINS'.0},{"role":"relay","maxLimit":40.0,"scaleAdjustment":1.0,"minLimit":'$RELAYS'.0}]}]}}}' - scale_policy_oet='{"policy":{"name":"'${scale_policy_name}'","description":"Terraform Scale policy Origin, Edge, Transcoder","type":"com.red5pro.services.autoscaling.model.ScalePolicyMaster","version": "0.0.3","targets":{"region":[{"name":"default","target":[{"role":"edge","maxLimit":80.0,"scaleAdjustment":1.0,"minLimit":'$EDGES'.0},{"role":"origin","maxLimit":40.0,"scaleAdjustment":1.0,"minLimit":'$ORIGINS'.0},{"role":"transcoder","maxLimit":40.0,"scaleAdjustment":1.0,"minLimit":'$TRANSCODERS'.0}]}]}}}' - scale_policy_oetr='{"policy":{"name":"'${scale_policy_name}'","description":"Terraform Scale policy Origin, Edge, Transcoder, Relay","type":"com.red5pro.services.autoscaling.model.ScalePolicyMaster","version": "0.0.3","targets":{"region":[{"name":"default","target":[{"role":"edge","maxLimit":80.0,"scaleAdjustment":1.0,"minLimit":'$EDGES'.0},{"role":"origin","maxLimit":40.0,"scaleAdjustment":1.0,"minLimit":'$ORIGINS'.0},{"role":"transcoder","maxLimit":40.0,"scaleAdjustment":1.0,"minLimit":'$TRANSCODERS'.0},{"role":"relay","maxLimit":40.0,"scaleAdjustment":1.0,"minLimit":'$RELAYS'.0}]}]}}}' + scale_policy_o='{"policy":{"name":"'${scale_policy_name}'","description":"Terraform Scale policy Origin","type":"com.red5pro.services.autoscaling.model.ScalePolicyMaster","version": "0.0.3","targets":{"region":[{"name":"default","target":[{"role":"origin","maxLimit":'$ORIGINS_MAX',"scaleAdjustment":1.0,"minLimit":'$ORIGINS_MIN'.0}]}]}}}' + scale_policy_oe='{"policy":{"name":"'${scale_policy_name}'","description":"Terraform Scale policy Origin, Edge","type":"com.red5pro.services.autoscaling.model.ScalePolicyMaster","version": "0.0.3","targets":{"region":[{"name":"default","target":[{"role":"edge","maxLimit":'$EDGES_MAX',"scaleAdjustment":1.0,"minLimit":'$EDGES_MIN'.0},{"role":"origin","maxLimit":'$ORIGINS_MAX',"scaleAdjustment":1.0,"minLimit":'$ORIGINS_MIN'.0}]}]}}}' + scale_policy_oer='{"policy":{"name":"'${scale_policy_name}'","description":"Terraform Scale policy Origin, Edge, Relay","type":"com.red5pro.services.autoscaling.model.ScalePolicyMaster","version": "0.0.3","targets":{"region":[{"name":"default","target":[{"role":"edge","maxLimit":'$EDGES_MAX',"scaleAdjustment":1.0,"minLimit":'$EDGES_MIN'.0},{"role":"origin","maxLimit":'$ORIGINS_MAX',"scaleAdjustment":1.0,"minLimit":'$ORIGINS_MIN'.0},{"role":"relay","maxLimit":'$RELAYS_MAX',"scaleAdjustment":1.0,"minLimit":'$RELAYS_MIN'.0}]}]}}}' + scale_policy_oet='{"policy":{"name":"'${scale_policy_name}'","description":"Terraform Scale policy Origin, Edge, Transcoder","type":"com.red5pro.services.autoscaling.model.ScalePolicyMaster","version": "0.0.3","targets":{"region":[{"name":"default","target":[{"role":"edge","maxLimit":'$EDGES_MAX',"scaleAdjustment":1.0,"minLimit":'$EDGES_MIN'.0},{"role":"origin","maxLimit":'$ORIGINS_MAX',"scaleAdjustment":1.0,"minLimit":'$ORIGINS_MIN'.0},{"role":"transcoder","maxLimit":'$TRANSCODERS_MAX',"scaleAdjustment":1.0,"minLimit":'$TRANSCODERS_MIN'.0}]}]}}}' + scale_policy_oetr='{"policy":{"name":"'${scale_policy_name}'","description":"Terraform Scale policy Origin, Edge, Transcoder, Relay","type":"com.red5pro.services.autoscaling.model.ScalePolicyMaster","version": "0.0.3","targets":{"region":[{"name":"default","target":[{"role":"edge","maxLimit":'$EDGES_MAX',"scaleAdjustment":1.0,"minLimit":'$EDGES_MIN'.0},{"role":"origin","maxLimit":'$ORIGINS_MAX',"scaleAdjustment":1.0,"minLimit":'$ORIGINS_MIN'.0},{"role":"transcoder","maxLimit":'$TRANSCODERS_MAX',"scaleAdjustment":1.0,"minLimit":'$TRANSCODERS_MIN'.0},{"role":"relay","maxLimit":'$RELAYS_MAX',"scaleAdjustment":1.0,"minLimit":'$RELAYS_MIN'.0}]}]}}}' } check_stream_manager(){ @@ -94,12 +99,17 @@ check_stream_manager(){ SM_STATUS_URL="http://$SM_IP:5080/streammanager/api/4.0/admin/debug/cloudcontroller?accessToken=$SM_API_KEY" for i in {1..20}; do - code_resp=$(curl -s -m 5 -o /dev/null -w "%{http_code}" "$SM_STATUS_URL") - if [ "$code_resp" -eq 200 ]; then - log_i "Stream Manager is running. Status code: $code_resp" - break + curl -s -m 5 -o /dev/null -w "%{http_code}" "$SM_STATUS_URL" > /dev/null + if [ $? -eq 0 ]; then + code_resp=$(curl -s -o /dev/null -w "%{http_code}" "$SM_STATUS_URL") + if [ "$code_resp" -eq 200 ]; then + log_i "Stream Manager is running. Status code: $code_resp" + break + else + log_i "Stream Manager is not running. Status code: $code_resp" + fi else - log_w "Test $i - Stream Manager is not running. Status code: $code_resp" + log_w "Cycle $i - Stream Manager is not running!" fi if [ "$i" -eq 20 ]; then @@ -174,8 +184,9 @@ add_origin_to_node_group(){ } check_node_group(){ + log_i "Checking states of nodes in new node group." - + sleep 30 NODES_URL="http://$SM_IP:5080/streammanager/api/4.0/admin/nodegroup/$NODE_GROUP_NAME/node?accessToken=$SM_API_KEY" for i in {1..10}; @@ -184,12 +195,6 @@ check_node_group(){ echo "$resp" |jq -r '.[] | [.identifier, .role, .state] | join(" ")' > temp.txt nodes=$(awk '{print $1}' < temp.txt) - - if [[ -z "$nodes" ]]; then - log_w "Nodes list is empty. Node group was not created." - log_e "Something wrong with Stream Manager in this build. EXIT..." - fi - node_bad_state=0 for index in $nodes @@ -206,7 +211,9 @@ check_node_group(){ if [[ $node_bad_state -ne 1 ]]; then log_i "All nodes are ready to go! :)" - rm temp.txt + if [ -f temp.txt ]; then + rm temp.txt + fi break fi if [[ $i -eq 10 ]]; then @@ -216,28 +223,28 @@ check_node_group(){ done } -if [ -z "$ORIGINS" ]; then - ORIGINS=0 +if [ -z "$ORIGINS_MIN" ]; then + ORIGINS_MIN=0 fi -if [ -z "$EDGES" ]; then - EDGES=0 +if [ -z "$EDGES_MIN" ]; then + EDGES_MIN=0 fi -if [ -z "$RELAYS" ]; then - RELAYS=0 +if [ -z "$RELAYS_MIN" ]; then + RELAYS_MIN=0 fi -if [ -z "$TRANSCODERS" ]; then - TRANSCODERS=0 +if [ -z "$TRANSCODERS_MIN" ]; then + TRANSCODERS_MIN=0 fi -if [ "$ORIGINS" -gt 0 ] && [ "$EDGES" -gt 0 ] && [ "$RELAYS" -gt 0 ] && [ "$TRANSCODERS" -gt 0 ]; then +if [ "$ORIGINS_MIN" -gt 0 ] && [ "$EDGES_MIN" -gt 0 ] && [ "$RELAYS_MIN" -gt 0 ] && [ "$TRANSCODERS_MIN" -gt 0 ]; then NODE_GROUP_TYPE="oetr" -elif [ "$ORIGINS" -gt 0 ] && [ "$EDGES" -gt 0 ] && [ "$RELAYS" -gt 0 ]; then +elif [ "$ORIGINS_MIN" -gt 0 ] && [ "$EDGES_MIN" -gt 0 ] && [ "$RELAYS_MIN" -gt 0 ]; then NODE_GROUP_TYPE="oer" -elif [ "$ORIGINS" -gt 0 ] && [ "$EDGES" -gt 0 ] && [ "$TRANSCODERS" -gt 0 ]; then +elif [ "$ORIGINS_MIN" -gt 0 ] && [ "$EDGES_MIN" -gt 0 ] && [ "$TRANSCODERS_MIN" -gt 0 ]; then NODE_GROUP_TYPE="oet" -elif [ "$ORIGINS" -gt 0 ] && [ "$EDGES" -gt 0 ]; then +elif [ "$ORIGINS_MIN" -gt 0 ] && [ "$EDGES_MIN" -gt 0 ]; then NODE_GROUP_TYPE="oe" -elif [ "$ORIGINS" -gt 0 ]; then +elif [ "$ORIGINS_MIN" -gt 0 ]; then NODE_GROUP_TYPE="o" else log_e "Node group type was not found: $NODE_GROUP_TYPE, EXIT..."; @@ -247,35 +254,35 @@ log_i "NODE_GROUP_TYPE: $NODE_GROUP_TYPE" case $NODE_GROUP_TYPE in o) - scale_policy_name="${NAME}-scale-policy-${ORIGINS}o-${timestamp}" + scale_policy_name="${NAME}-scale-policy-${ORIGINS_MIN}o-${timestamp}" launch_config_name="${NAME}-launch-config-o-${timestamp}" prepare_json_templates scale_policy=$scale_policy_o launch_config=$launch_config_o ;; oe) - scale_policy_name="${NAME}-scale-policy-${ORIGINS}o-${EDGES}e-${timestamp}" + scale_policy_name="${NAME}-scale-policy-${ORIGINS_MIN}o-${EDGES_MIN}e-${timestamp}" launch_config_name="${NAME}-launch-config-oe-${timestamp}" prepare_json_templates scale_policy=$scale_policy_oe launch_config=$launch_config_oe ;; oer) - scale_policy_name="${NAME}-scale-policy-${ORIGINS}o-${EDGES}e-${RELAYS}r-${timestamp}" + scale_policy_name="${NAME}-scale-policy-${ORIGINS_MIN}o-${EDGES_MIN}e-${RELAYS_MIN}r-${timestamp}" launch_config_name="${NAME}-launch-config-oer-${timestamp}" prepare_json_templates scale_policy=$scale_policy_oer launch_config=$launch_config_oer ;; oet) - scale_policy_name="${NAME}-scale-policy-${ORIGINS}o-${EDGES}e-${TRANSCODERS}t-${timestamp}" + scale_policy_name="${NAME}-scale-policy-${ORIGINS_MIN}o-${EDGES_MIN}e-${TRANSCODERS_MIN}t-${timestamp}" launch_config_name="${NAME}-launch-config-oet-${timestamp}" prepare_json_templates scale_policy=$scale_policy_oet launch_config=$launch_config_oet ;; oetr) - scale_policy_name="${NAME}-scale-policy-${ORIGINS}o-${EDGES}e-${TRANSCODERS}t-${RELAYS}r-${timestamp}" + scale_policy_name="${NAME}-scale-policy-${ORIGINS_MIN}o-${EDGES_MIN}e-${TRANSCODERS_MIN}t-${RELAYS_MIN}r-${timestamp}" launch_config_name="${NAME}-launch-config-oetr-${timestamp}" prepare_json_templates scale_policy=$scale_policy_oetr diff --git a/variables.tf b/variables.tf index ec1e94c..0b398db 100644 --- a/variables.tf +++ b/variables.tf @@ -1026,10 +1026,15 @@ variable "node_group_name" { type = string default = "terraform-node-group" } -variable "node_group_origins" { - description = "Number of Origins" +variable "node_group_origins_min" { + description = "Number of minimum Origins" type = number - default = 0 + default = 1 +} +variable "node_group_origins_max" { + description = "Number of maximum Origins" + type = number + default = 20 } variable "node_group_origins_instance_type" { description = "Instance type for Origins" @@ -1041,10 +1046,15 @@ variable "node_group_origins_capacity" { type = number default = 30 } -variable "node_group_edges" { - description = "Number of Edges" +variable "node_group_edges_min" { + description = "Number of minimum Edges" + type = number + default = 1 +} +variable "node_group_edges_max" { + description = "Number of maximum Edges" type = number - default = 0 + default = 40 } variable "node_group_edges_instance_type" { description = "Instance type for Edges" @@ -1056,10 +1066,15 @@ variable "node_group_edges_capacity" { type = number default = 300 } -variable "node_group_transcoders" { - description = "Number of Transcoders" +variable "node_group_transcoders_min" { + description = "Number of minimum Transcoders" type = number - default = 0 + default = 1 +} +variable "node_group_transcoders_max" { + description = "Number of maximum Transcoders" + type = number + default = 20 } variable "node_group_transcoders_instance_type" { description = "Instance type for Transcoders" @@ -1071,10 +1086,15 @@ variable "node_group_transcoders_capacity" { type = number default = 30 } -variable "node_group_relays" { - description = "Number of Relays" +variable "node_group_relays_min" { + description = "Number of minimum Relays" + type = number + default = 1 +} +variable "node_group_relays_max" { + description = "Number of maximum Relays" type = number - default = 0 + default = 20 } variable "node_group_relays_instance_type" { description = "Instance type for Relays"