Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Archive Terraform Crash File (errored.tfstate) - Failed to save state/Failed to persist state to backend #429

Open
vincentclee opened this issue Feb 4, 2022 · 0 comments

Comments

@vincentclee
Copy link
Contributor

The Terraform Crash File (errored.tfstate) file is lost when Terraform Pipeline finishes with a failure. Save the (errored.tfstate) when the errors occur to persist state to backend.

Example Fix

post {
    always {
        script {
            if (fileExists("errored.tfstate")) {
                archiveArtifacts artifacts: "errored.tfstate", fingerprint: true
            }
        }
    }
}

Error Message

 ╷
 │ Error: Failed to save state
 │ 
 │ Error saving state: failed to upload state: AccessDenied: Access Denied
 │ 	status code: 403, request id: FFFFFFFFFFFFFFFF, host id:
 │ V2h5IGFyZSB5b3UgcmVhZGluZyB0aGlzIHNvbHV0aW9uPw==
 ╵
 ╷
 │ Error: Failed to persist state to backend
 │ 
 │ The error shown above has prevented Terraform from writing the updated
 │ state to the configured backend. To allow for recovery, the state has been
 │ written to the file "errored.tfstate" in the current working directory.
 │ 
 │ Running "terraform apply" again at this point will create a forked state,
 │ making it harder to recover.
 │ 
 │ To retry writing this state, use the following command:
 │     terraform state push errored.tfstate
 │ 
 ╵
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant