Introduction
If remote run in Terraform Cloud is triggered, the first few lines that are shown are something like:
Terraform v1.0.8
on linux_amd64
Configuring remote state backend...
Initializing Terraform configuration...
Under normal conditions, after couple of seconds, the log file will continue growing, adding the new events to the run.
Problem
Sometimes runs may look "stuck" after "Initializing Terraform configuration..." and no further events are generated.
Looking at the last log entry "Initializing Terraform configuration..." the assumption could be that "Terraform Cloud run is stuck during the init phase".
Cause
The next entry after "Initializing Terraform configuration.." would be the first output of terraform plan/apply command.
Sometimes Terraform plan/apply command may run for some time before writing any output.
For example if invalid/expired AWS credentials are used, Terraform will silently retry the failing API requests for 25 times before producing any output, which may take some time.
During this time, the user may misinterpret the Terraform run state as Initializing, while Terraform plan/apply is actually already Running.
Solution
In order to confirm this behaviour, the user can add environment variable `TF_LOG` with value `TRACE` into the target Terraform Cloud workspace and then trigger a new run.
Enabling trace logging will make the Terraform plan/apply command provide output as soon as it has started, therefore providing more information on Terraform's activity.
Additional Information
If after reviewing the TRACE log, you are still not able to solve your issue, please reach out Terraform Cloud support at tf-cloud@hashicorp.support or submit a ticket via our support portal.