ecsjobs.jobs.ecs_task module
- class ecsjobs.jobs.ecs_task.EcsTask(name, schedule, summary_regex=None, cron_expression=None, cluster_name=None, task_definition_family=None, overrides=None, network_configuration=None)[source]
Bases:
JobClass to run an ECS Task asynchronously; starts the task with the
run()method and then usespoll()to wait for it to finish. Setsexitcodeaccording to:if only one container in the task, the exit code of that container
otherwise, the maximum exit code of all containers
- Parameters:
name (str) – unique name for this job
schedule (str) – the name of the schedule this job runs on
summary_regex (
stringorNone) – A regular expression to use for extracting a string from the job output for use in the summary table. If there is more than one match, the last one will be used.cron_expression (str) – A cron-like expression parsable by cronex specifying when the job should run. This has the effect of causing runs to skip this job unless the expression matches. It’s recommended not to use any minute specifiers and not to use any hour specifiers if the total runtime of all jobs is more than an hour.
cluster_name (str) – name of the ECS cluster to run the task on
task_definition_family (str) – Name of the Task Definition family to run
overrides (dict) – RunTask overrides hash/mapping/dict to pass to ECS RunTask API call, as specified in the documentation for
ECS.Client.run_task()network_configuration (dict) – RunTask networkConfiguration parameter to pass to ECS API call, as specified in the documentation for
ECS.Client.run_task()
- _log_info_for_task(task_family)[source]
Return a dictionary of container name to 2-tuple of Log Group Name and Log Stream Prefix, for each container in the specified Task Definition that uses the
awslogslog driver.
- _output_for_task_container(taskid, cont_name)[source]
Update
self.outputwith the CloudWatch logs for the containers in the task.
- _schema_dict = {'properties': {'cluster_name': {'type': 'string'}, 'network_configuration': {'type': 'object'}, 'overrides': {'type': 'object'}, 'task_definition_family': {'type': 'string'}}, 'required': ['cluster_name', 'task_definition_family'], 'type': 'object'}
Dictionary describing the configuration file schema, to be validated with jsonschema.
- poll()[source]
Poll to check status on the task. If STOPPED, set this Job as finished and collect report information.
- Returns:
whether or not the Task is finished
- Return type: