Problem
The specific error below is encountered when attempting to upload a new state file version to Terraform Cloud/Enterprise (TFC/E) for a workspace.
{
"errors": [
{
"status": "412",
"title": "Precondition Failed",
"detail": "The serial provided in the state file is not greater than the serial\ncurrently known remotely. This means that there may be an update performed\nsince your version of that state. Update to the latest state to resolve\nconflicts and try again"
}
]
}
Cause
- The integer provided for the serial property in the payload of the API request is not the same, or greater, than the serial number of the latest state version object that exists in TFC/E for the workspace.
- The API does not restrict the value for serial in the state file itself. It is only requiring that the serial value for the new state version be the same or higher than the number that is currently set for the latest state version in the workspace.
- The API does not restrict the value for serial in the state file itself. It is only requiring that the serial value for the new state version be the same or higher than the number that is currently set for the latest state version in the workspace.
Solution:
- Uncover what the current value is for serial for the latest state version that exists within the workspace by using the Current State Version API endpoint.
- Increment the number you have configured for
data.attributes.serial
in the payload JSON object to supersede the previously set integer, or set it to be the same value as the value for the currently uploaded state file, if desired. - Invoke the API request again to create a new state version.