terraform-cdk icon indicating copy to clipboard operation
terraform-cdk copied to clipboard

Intermittent Terraform Cloud Connection Failures in GitHub Actions

Open KentonParton opened this issue 8 months ago • 1 comments

Expected Behavior

When running pnpm exec cdktf deploy stack-name --auto-approve within GitHub Actions, the workflow should complete successfully with a proper JSON response from Terraform Cloud after the apply operation completes.

Actual Behavior

While the actual Terraform apply operation completes successfully (resources are correctly created/modified/destroyed), the connection to Terraform Cloud sometimes drops during the final output phase. This results in a JSON parsing error and causes the GitHub Actions workflow to fail with exit code 201. Error message:

     Apply complete! Resources: 1 added, 0 changed, 1 destroyed.


0 Stacks deploying     1 Stack done     0 Stacks waiting
Error: External Error: Failed to parse terraform output: SyntaxError: Unexpected token 'T', "There was "... is not valid JSON. The output was 'There was an error connecting to Terraform Cloud. Please do not exit
Terraform to prevent data loss! Trying to restore the connection...

Still trying to restore the connection... (3s elapsed)
{}
'
task: Failed to run task "deploy:terraform-shared": exit status 1
Error: Process completed with exit code 201.

Steps to Reproduce

Unfortunately, the issue is intermittent. I have not been able to reproduce consistently

Versions

❯ cdktf debug cdktf debug language: typescript cdktf-cli: 0.20.11 node: v20.9.0 cdktf: 0.20.10 constructs: 10.4.2 jsii: null terraform: 1.5.7 arch: arm64 os: darwin 24.1.0 providers timescale/timescale@~> 1.12 (LOCAL) terraform provider version: 1.13.1 @cdktf/provider-github (PREBUILT) terraform provider version: 6.4.0 prebuilt provider version: 14.4.0 cdktf version: ^0.20.0 @cdktf/provider-google-beta (PREBUILT) terraform provider version: 6.14.0 prebuilt provider version: 14.13.0 cdktf version: ^0.20.0 @cdktf/provider-null (PREBUILT) terraform provider version: 3.2.3 prebuilt provider version: 10.0.1 cdktf version: ^0.20.0 @cdktf/provider-tfe (PREBUILT) terraform provider version: 0.61.0 prebuilt provider version: 11.10.0 cdktf version: ^0.20.0

Providers

─────────────────────────────────────┬────────┬───────────┬──────────────────────────┬────────────────┐ ── Provider Name Provider Version│ CDKTF │ Constraint│ Package Name │ Package Version│

─────────────────────────────────────┼────────┼───────────┼──────────────────────────┼────────────────┤ ── timescale/timescale 1.13.1 │ │ ~> 1.12 │ │ │

─────────────────────────────────────┼────────┼───────────┼──────────────────────────┼────────────────┤ ── integrations/github 6.4.0 │ ^0.20.0│ │ @cdktf/provider-github │ 14.4.0 │

─────────────────────────────────────┼────────┼───────────┼──────────────────────────┼────────────────┤ ── google-beta 6.14.0 │ ^0.20.0│ │ │ 14.13.0 │ @cdktf/provider-google-beta

─────────────────────────────────────┼────────┼───────────┼──────────────────────────┼────────────────┤ ── null 3.2.3 │ ^0.20.0│ │ @cdktf/provider-null │ 10.0.1 │

─────────────────────────────────────┼────────┼───────────┼──────────────────────────┼────────────────┤ ── tfe 0.61.0 │ ^0.20.0│ │ @cdktf/provider-tfe │ 11.10.0 │

─────────────────────────────────────┴────────┴───────────┴──────────────────────────┴────────────────┘

Gist

No response

Possible Solutions

No response

Workarounds

No response

Anything Else?

No response

References

No response

Help Wanted

  • [ ] I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

KentonParton avatar Feb 24 '25 23:02 KentonParton