variable "api_image_uri" { type = string } variable "frontend_image_uri" { type = string } variable "aws_access_token" { type = string } job "site" { group "frontend" { count = 3 network { mode = "bridge" port "frontend" { static = 3000 to = 3000 } } restart { # The number of attempts to run the job within the specified interval. attempts = 10 interval = "5m" # The "delay" parameter specifies the duration to wait before restarting # a task after it has failed. delay = "25s" # The "mode" parameter controls what happens when a task has restarted # "attempts" times within the interval. "delay" mode delays the next # restart until the next interval. "fail" mode does not restart the task # if "attempts" has been hit within the interval. mode = "delay" } service { provider = "consul" name = "frontend" port = "frontend" check { type = "http" port = "frontend" path = "/" method = "GET" interval = "10s" timeout = "10s" } } task "frontend" { driver = "docker" config { image = var.frontend_image_uri // The container registry auth info auth { username = "AWS" password = "${var.aws_access_token}" } } env { ENVIRONMENT = "consul" } resources { cpu = 200 memory = 128 memory_max = 512 } } update { max_parallel = 2 auto_revert = true } } group "api" { count = 3 ephemeral_disk { size = 60000 } network { mode = "bridge" port "api" { static = 4000 to = 4000 } } service { provider = "consul" name = "api" port = "api" check { type = "http" port = "api" path = "/" method = "GET" interval = "10s" timeout = "2s" } } task "api" { driver = "docker" config { image = var.api_image_uri // The container registry auth info auth { username = "AWS" password = "${var.aws_access_token}" } } env { ENVIRONMENT = "consul" } resources { cpu = 500 memory = 2048 memory_max = 8192 } } spread { attribute = "${node.unique.id}" } update { max_parallel = 2 auto_revert = true } } }