Introduction:
This article explains a scenario were a HCP Terraform run fails due to a Sentinel Policy with a message:
Error: unable to display. Please download all logs to view
Problem
HCP Terraform Sentinel policies window shows a hard fail status with 0 failed policies.
and displays the following message:Error: unable to display. Please download all logs to view
When you click Download all logs the policy-check-log.txt
file shows:
An error occurred: unexpected EOF
Cause
This error occurs when the state file has grown to a considerable size, impeding the sentinel system complete reading all the contents to process the defined policies.
Solutions:
Check the state file size:
Navigate to:https://app.terraform.io/app/<Organization>/workspaces/<Workspace>/states
Confirm the state file for the failed run is readable in the browser through HCP Terraform.
If it shows the warning:
State file too large to display (xxx MB compressed)
Review what configuration is causing the state file to be this large.
Follow workspace configuration best practices:
https://developer.hashicorp.com/terraform/cloud-docs/workspaces/best-practices