AMC API: HTTP 400 when cancelling a finished execution
An execution status can only be set to CANCELLED while it is PENDING or RUNNING; for finished executions the API answers 400.
Symptom
Updating an execution to CANCELLED answers with 400.
Cause
According to the API reference, updating an execution that is FAILED, SUCCEEDED or CANCELLED results in a 400 response.
Fix
- Read the status before cancelling and only cancel PENDING or RUNNING executions.
- Treat a 400 for an already finished target as done, not as a failure.
The cause follows the Amazon documentation. Some of the fix steps are our own judgement and do not replace asking Amazon support.