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 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