Managing jobs
Use jobs to notify devices of a software or firmware update. You can use the
AWS IoT console
Code signing for jobs
When sending code to devices, for devices to detect whether the code has been modified in transit, we recommend that you sign the code file by using the AWS CLI. For instructions, see Create and manage jobs by using the AWS CLI.
For more information, see What Is Code Signing for AWS IoT?.
Job document
Before you create a job, you must create a job document. If you're using code signing for AWS IoT, you must upload your job document to a versioned Amazon S3 bucket. For more information about creating an Amazon S3 bucket and uploading files to it, see Getting Started with Amazon Simple Storage Service in the Amazon S3 Getting Started Guide.
For job document examples, see the jobs-agent.js
Presigned URLs
Your job document can contain a presigned Amazon S3 URL that points to your code file (or other file). Presigned Amazon S3 URLs are valid only for a limited amount of time and are generated when a device requests a job document. Because the presigned URL isn't created when you're creating the job document, use a placeholder URL in your job document instead. A placeholder URL looks like the following:
${aws:iot:s3-presigned-url:https://s3.region.amazonaws.com/
<bucket>
/<code
file>
}
where:
-
bucket
is the Amazon S3 bucket that contains the code file. -
code file
is the Amazon S3 key of the code file.
When a device requests the job document, AWS IoT generates the presigned URL and replaces the placeholder URL with the presigned URL. Your job document is then sent to the device.
IAM role to grant permission to download files from S3
When you create a job that uses presigned Amazon S3 URLs, you must provide an IAM role that grants permission to download files from the Amazon S3 bucket where the data or updates are stored. The role must also grant permission for AWS IoT to assume the role.
You can specify an optional timeout for the presigned URL. For more information, see CreateJob.
Grant AWS IoT Jobs permission to assume your role
-
Go to the Roles hub of the IAM console
and choose your role. -
On the Trust Relationships tab, choose Edit Trust Relationship and replace the policy document with the following JSON. Choose Update Trust Policy.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": [ "iot.amazonaws.com" ] }, "Action": "sts:AssumeRole" } ] }
-
To protect against the confused deputy problem, add the global condition context keys
aws:SourceArn
andaws:SourceAccount
to the policy.Important Your
aws:SourceArn
must comply with the format:arn:aws:iot:
. Make sure thatregion
:account-id
:*region
matches your AWS IoT Region andaccount-id
matches your customer account ID. For more information, see Cross-service confused deputy prevention.{ "Effect": "Allow", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "iot.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:SourceAccount": "123456789012" }, "ArnLike": { "aws:SourceArn": "arn:aws:iot:*:123456789012:job/*" } } } ] }
-
If your job uses a job document that's an Amazon S3 object, choose Permissions and with the following JSON, add a policy that grants permission to download files from your Amazon S3 bucket:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::
your_S3_bucket
/*" } ] }
Topics