From 7d4adcd0f958fe3081c28d71074a28fd08f917ef Mon Sep 17 00:00:00 2001 From: zac Date: Fri, 17 May 2019 11:11:11 +1000 Subject: [PATCH 1/2] Don't set DesiredCount when using the daemon scheduling strategy. ECS doesn't allow it. --- ecs-service.cfndsl.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ecs-service.cfndsl.rb b/ecs-service.cfndsl.rb index 0738f74..7e9c6ef 100644 --- a/ecs-service.cfndsl.rb +++ b/ecs-service.cfndsl.rb @@ -364,16 +364,18 @@ desired_count = desired end + strategy = defined?(scheduling_strategy) ? scheduling_strategy : nil + ECS_Service('Service') do Cluster Ref("EcsCluster") Property("HealthCheckGracePeriodSeconds", health_check_grace_period) if defined? health_check_grace_period - DesiredCount Ref('DesiredCount') + DesiredCount Ref('DesiredCount') if strategy != 'DAEMON' DeploymentConfiguration ({ MinimumHealthyPercent: Ref('MinimumHealthyPercent'), MaximumPercent: Ref('MaximumPercent') }) TaskDefinition Ref('Task') - SchedulingStrategy scheduling_strategy if defined? scheduling_strategy + SchedulingStrategy scheduling_strategy if !strategy.nil? if service_loadbalancer.any? Role Ref('Role') unless awsvpc_enabled From a05f1779880fff979dece2a85a0a30d26a83f767 Mon Sep 17 00:00:00 2001 From: zac Date: Wed, 17 Jul 2019 11:53:54 +1000 Subject: [PATCH 2/2] Add tests for scheduling strategy. --- tests/scheduling-strategy-daemon.test.yaml | 14 ++++++++++++++ tests/scheduling-strategy-default.test.yaml | 12 ++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/scheduling-strategy-daemon.test.yaml create mode 100644 tests/scheduling-strategy-default.test.yaml diff --git a/tests/scheduling-strategy-daemon.test.yaml b/tests/scheduling-strategy-daemon.test.yaml new file mode 100644 index 0000000..46bf096 --- /dev/null +++ b/tests/scheduling-strategy-daemon.test.yaml @@ -0,0 +1,14 @@ +test_metadata: + type: config + name: ecs service with daemon scheduling + description: Creates an ECS service with the daemon scheduling strategy + +scheduling_strategy: DAEMON + +task_definition: + sftp: + image: nginx + tag: latest + privileged: true + ports: + - 80 diff --git a/tests/scheduling-strategy-default.test.yaml b/tests/scheduling-strategy-default.test.yaml new file mode 100644 index 0000000..291a95b --- /dev/null +++ b/tests/scheduling-strategy-default.test.yaml @@ -0,0 +1,12 @@ +test_metadata: + type: config + name: ecs service with replica scheduling + description: Creates an ECS service with the default (replica) scheduling strategy + +task_definition: + sftp: + image: nginx + tag: latest + privileged: true + ports: + - 80