2
votes

The boto3 documentation describes a function to delete a job. See: https://boto3.readthedocs.io/en/latest/reference/services/iot.html#IoT.Client.delete_job

I have written a Lambda that can successfully create_job, cancel_job, and list_job_executions_for_thing. The delete_job function doesn't work.

Using the example from the boto3 documentation:

client=boto3.client('iot')
    response = client.delete_job(
    jobId='Upgrade00003',
    force=True
)

Gives the following error:

{
  "errorMessage": "'IoT' object has no attribute 'delete_job'",
  "errorType": "AttributeError",
  "stackTrace": [
    [
      "/var/task/lambda_function.py",
      162,
      "lambda_handler",
      "response = client.delete_job("
    ],
    [
      "/var/runtime/botocore/client.py",
      555,
      "__getattr__",
      "self.__class__.__name__, item)"
    ]
  ]
}

"iot:DeleteJob" also does not show up as an option in the IAM Role permissions.

Is the delete_job boto3 function not implemented by AWS?

2

2 Answers

0
votes

I tried it and got the same error, but then upgraded boto3:

pip install boto3 --upgrade

The resulting version was:

Successfully installed boto3-1.7.34 botocore-1.10.34

The delete_job() command now works.

0
votes

Adding newer boto3 to the Lambda code enabled delete_job(), but unfortunately the package is now to big to support inline editing.