diff --git a/ecs_taskdefinition.py b/ecs_taskdefinition.py index f99db8b9659..c74bf44ec9d 100644 --- a/ecs_taskdefinition.py +++ b/ecs_taskdefinition.py @@ -923,13 +923,16 @@ def _right_has_values_of_left(left, right): return True - def _task_definition_matches(requested_volumes, requested_containers, requested_task_role_arn, existing_task_definition): + def _task_definition_matches(requested_volumes, requested_containers, requested_task_role_arn, requested_launch_type, existing_task_definition): if td['status'] != "ACTIVE": return None if requested_task_role_arn != td.get('taskRoleArn', ""): return None + if requested_launch_type is not None and requested_launch_type not in td.get('compatibilities', []): + return None + existing_volumes = td.get('volumes', []) or [] if len(requested_volumes) != len(existing_volumes): @@ -972,7 +975,8 @@ def _task_definition_matches(requested_volumes, requested_containers, requested_ requested_volumes = module.params['volumes'] or [] requested_containers = module.params['containers'] or [] requested_task_role_arn = module.params['task_role_arn'] - existing = _task_definition_matches(requested_volumes, requested_containers, requested_task_role_arn, td) + requested_launch_type = module.params['launch_type'] + existing = _task_definition_matches(requested_volumes, requested_containers, requested_task_role_arn, requested_launch_type, td) if existing: break