Skip to main content

jobs

Creates, updates, deletes, gets or lists a jobs resource.

Overview

Namejobs
TypeResource
Idaws.iot.jobs

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
document_sourcestringAn S3 link to the job document.
jobobjectInformation about the job.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_jobselectjob_id, regionbeforeSubstitutionDescribes a job. Requires permission to access the DescribeJob action.
list_jobsselectregionstatus, targetSelection, maxResults, nextToken, thingGroupName, thingGroupId, namespaceIdLists jobs. Requires permission to access the ListJobs action.
create_jobinsertjob_id, region, targetsCreates a job. Requires permission to access the CreateJob action.
associate_targets_with_jobupdatejob_id, region, targetsnamespaceIdAssociates a group with a continuous job. The following criteria must be met: The job must have been created with the targetSelection field set to "CONTINUOUS". The job status must currently be "IN_PROGRESS". The total number of targets associated with a job must not exceed 100. Requires permission to access the AssociateTargetsWithJob action.
update_jobupdatejob_id, regionnamespaceIdUpdates supported fields of the specified job. Requires permission to access the UpdateJob action.
delete_jobdeletejob_id, regionforce, namespaceIdDeletes a job and its related job executions. Deleting a job may take time, depending on the number of job executions created for the job and various other factors. While the job is being deleted, the status of the job will be shown as "DELETION_IN_PROGRESS". Attempting to delete or cancel a job whose status is already "DELETION_IN_PROGRESS" will result in an error. Only 10 jobs may have status "DELETION_IN_PROGRESS" at the same time, or a LimitExceededException will occur. Requires permission to access the DeleteJob action.
cancel_jobexecjob_id, regionforceCancels a job. Requires permission to access the CancelJob action.
cancel_job_executionexecjob_id, thing_name, regionforceCancels the execution of a job for a given thing. Requires permission to access the CancelJobExecution action.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
job_idstringThe ID of the job to be canceled.
regionstringAWS region (default: us-east-1)
thing_namestringThe name of the thing whose execution of the job will be canceled.
beforeSubstitutionbooleanProvides a view of the job document before and after the substitution parameters have been resolved with their exact values.
forceboolean(Optional) If true the job execution will be canceled if it has status IN_PROGRESS or QUEUED, otherwise the job execution will be canceled only if it has status QUEUED. If you attempt to cancel a job execution that is IN_PROGRESS, and you do not set force to true, then an InvalidStateTransitionException will be thrown. The default is false. Canceling a job execution which is "IN_PROGRESS", will cause the device to be unable to update the job execution status. Use caution and ensure that the device is able to recover to a valid state.
maxResultsintegerThe maximum number of results to return per request.
namespaceIdstringThe namespace used to indicate that a job is a customer-managed job. When you specify a value for this parameter, Amazon Web Services IoT Core sends jobs notifications to MQTT topics that contain the value in the following format. $aws/things/THING_NAME/jobs/JOB_ID/notify-namespace-NAMESPACE_ID/ The namespaceId feature is only supported by IoT Greengrass at this time. For more information, see Setting up IoT Greengrass core devices.
nextTokenstringThe token to retrieve the next set of results.
statusstringAn optional filter that lets you search for jobs that have the specified status.
targetSelectionstringSpecifies whether the job will continue to run (CONTINUOUS), or will be complete after all those things specified as targets have completed the job (SNAPSHOT). If continuous, the job may also be run on a thing when a change is detected in a target. For example, a job will run on a thing when the thing is added to a target group, even after the job was completed by all things originally in the group. We recommend that you use continuous jobs instead of snapshot jobs for dynamic thing group targets. By using continuous jobs, devices that join the group receive the job execution even after the job has been created.
thingGroupIdstringA filter that limits the returned jobs to those for the specified group.
thingGroupNamestringA filter that limits the returned jobs to those for the specified group.

SELECT examples

Describes a job. Requires permission to access the DescribeJob action.

SELECT
document_source,
job
FROM aws.iot.jobs
WHERE job_id = '{{ job_id }}' -- required
AND region = '{{ region }}' -- required
AND beforeSubstitution = '{{ beforeSubstitution }}'
;

INSERT examples

Creates a job. Requires permission to access the CreateJob action.

INSERT INTO aws.iot.jobs (
targets,
documentSource,
document,
description,
presignedUrlConfig,
targetSelection,
jobExecutionsRolloutConfig,
abortConfig,
timeoutConfig,
tags,
namespaceId,
jobTemplateArn,
jobExecutionsRetryConfig,
documentParameters,
schedulingConfig,
destinationPackageVersions,
job_id,
region
)
SELECT
'{{ targets }}' /* required */,
'{{ documentSource }}',
'{{ document }}',
'{{ description }}',
'{{ presignedUrlConfig }}',
'{{ targetSelection }}',
'{{ jobExecutionsRolloutConfig }}',
'{{ abortConfig }}',
'{{ timeoutConfig }}',
'{{ tags }}',
'{{ namespaceId }}',
'{{ jobTemplateArn }}',
'{{ jobExecutionsRetryConfig }}',
'{{ documentParameters }}',
'{{ schedulingConfig }}',
'{{ destinationPackageVersions }}',
'{{ job_id }}',
'{{ region }}'
RETURNING
description,
job_arn,
job_id
;

UPDATE examples

Associates a group with a continuous job. The following criteria must be met: The job must have been created with the targetSelection field set to "CONTINUOUS". The job status must currently be "IN_PROGRESS". The total number of targets associated with a job must not exceed 100. Requires permission to access the AssociateTargetsWithJob action.

UPDATE aws.iot.jobs
SET
targets = '{{ targets }}',
comment = '{{ comment }}'
WHERE
job_id = '{{ job_id }}' --required
AND region = '{{ region }}' --required
AND targets = '{{ targets }}' --required
AND namespaceId = '{{ namespaceId}}'
RETURNING
description,
job_arn,
job_id;

DELETE examples

Deletes a job and its related job executions. Deleting a job may take time, depending on the number of job executions created for the job and various other factors. While the job is being deleted, the status of the job will be shown as "DELETION_IN_PROGRESS". Attempting to delete or cancel a job whose status is already "DELETION_IN_PROGRESS" will result in an error. Only 10 jobs may have status "DELETION_IN_PROGRESS" at the same time, or a LimitExceededException will occur. Requires permission to access the DeleteJob action.

DELETE FROM aws.iot.jobs
WHERE job_id = '{{ job_id }}' --required
AND region = '{{ region }}' --required
AND force = '{{ force }}'
AND namespaceId = '{{ namespaceId }}'
;

Lifecycle Methods

Cancels a job. Requires permission to access the CancelJob action.

EXEC aws.iot.jobs.cancel_job
@job_id='{{ job_id }}' --required,
@region='{{ region }}' --required,
@force={{ force }}
@@json=
'{
"reasonCode": "{{ reasonCode }}",
"comment": "{{ comment }}"
}'
;