ECS Cluster
By default, the ECS cluster UFO uses is whatever UFO_ENV
is set to. Since the default UFO_ENV=dev
, this means the ECS cluster named “dev” will be used. You can override this setting.
Cluster Setting
.ufo/config.rb
Ufo.configure do |config|
config.ecs.cluster = ":ENV-cluster"
end
Here we’re overriding the cluster name with :ENV-cluster
. The setting is a pattern that UFO expands. When UFO_ENV=dev
:ENV-cluster => dev-cluster
So ufo will deploy your application to the ECS cluster name “dev-cluster”.
Deployment Configuration
The ecs.maximum_percent
and ecs.minimum_healthy_percent
can be set to control the rolling deploy percentages. Example:
Ufo.configure do |config|
config.ecs.maximum_percent = 300
config.ecs.minimum_healthy_percent = 100
end
Important: You should not set the ecs.maximum_percent
to below 200 if you only have 1 container and want it to able to scale to 2. See: Debugging Deployment Configuration.
Cluster Setting as Callable Option
This is an advanced technique. For really custom control, you can also assign config.ecs.cluster
a Ruby object that implements the .call
method. Example:
.ufo/config.rb
class ClusterName
def call(names)
case names.env
when "prod"
"prod-cluster"
when "dev", "sbx", "uat"
"dev-cluster"
else
"qa-cluster"
end
end
end
Ufo.configure do |config|
config.ecs.cluster = ClusterName # implements call method
end
When UFO_ENV=prod
, the ECS Service uses the prod-cluster. When the UFO_ENV
is dev, sbx, or uat, the the dev-cluster. And for other UFO_ENV
values, the qa-cluster is used.
Note, the names
argument is an instance of the Ufo::Names class.
Reference
The table below covers each setting. Each option is configured in .ufo/config.rb
with config.OPTION
. The config.
portion is not shown for conciseness. IE: logger.level
vs config.logger.level
.
Name | Default | Description |
---|---|---|
ecs.cluster | :ENV | Notice that the default is a pattern. By default, the :ENV pattern is expanded as the value of env var UFO_ENV=dev . So, by convention, the ECS cluster that ufo deploys to matches the UFO_ENV . If UFO=prod , then ufo ship deploys to the prod ECS cluster. This is option overrides this convention. |
ecs.deployment_configuration | nil | Full control over the DeploymentConfiguration.This option is passed straight through to the CloudFormation template, so you should use CamelCase for the keys. Also when used, overrides ecs.maximum_percent and ecs.minimum_healthy_percent . |
ecs.desired_count. | nil | Only respected when autoscaling.enabled = false . |
ecs.maximum_percent | 200 | Upper limit on the number of tasks in a service that are allowed in the RUNNING or PENDING state during a deployment. This is part of DeploymentConfiguration. |
ecs.minimum_healthy_percent | 100 | Lower limit on the number of tasks in a service that must remain in the RUNNING state during a deployment. This is part of DeploymentConfiguration. |
ecs.scheduling_strategy | REPLICA | ECS Scheduling Strategy. IE: REPLICA or DAEMON |