Hi, thanks for creating this framework. It’s been fantastic so far. I’m in the process of setting up Terraspace deployments in CI using GitHub Actions and am running into issues that only manifest on the GitHub runner but works fine locally.
I have 2 stacks, infra
and backstage
and the latter depends on the first. The base.tfvars
for that stack looks like this:
# Required variables:
db_name = <%= output("infra.db_name") %>
# Optional variables:
namespace = "default"
The outputs.tf
for infra
looks like this:
output "db_name" {
description = "SQL database configuration"
value = module.sql_db.name
}
When running in GHA, I’m running into this error:
Bundle complete! 5 Gemfile dependencies, 89 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Building .terraspace-cache/us-central1/prd/stacks/backstage
JSON::ParserError: unexpected token at 'command]/home/runner/work/_temp/40a8b396-95f5-4924-a790-2f3b0684087f/terraform-bin state pull
<lot of JSON text>
Error evaluating ERB template around line 2 of: /home/runner/work/rs-backstage-web/rs-backstage-web/deployment/app/stacks/backstage/tfvars/base.tfvars:
1 # Required variables:
2 db_name = <%= output("infra.db_name") %>
3
4 # Optional variables:
5 namespace = "default"
Original backtrace (last 8 lines):
/opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/3.2.0/json/common.rb:216:in `parse'
/opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/3.2.0/json/common.rb:216:in `parse'
/opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/3.2.0/json/common.rb:569:in `load'
/opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/terraspace-2.2.3/lib/terraspace/terraform/remote_state/fetcher.rb:120:in `read_statefile_outputs'
/opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/terraspace-2.2.3/lib/terraspace/terraform/remote_state/fetcher.rb:108:in `load'
/opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/memoist-0.16.2/lib/memoist.rb:169:in `load'
/opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/terraspace-2.2.3/lib/terraspace/terraform/remote_state/fetcher.rb:18:in `run'
/opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/terraspace-2.2.3/lib/terraspace/terraform/remote_state/fetcher.rb:23:in `output'
I have the same versions locally and running these commands never yields this failure. The GHA steps in short looks roughly like this:
# Provision the infrastructure
- name: Provision Infra
run: |-
make infra-up
...
# Deploy the services to the GKE cluster
- name: Deploy
run: |-
make apply
Any help or guidance would be greatly appreciated as I’m at a bit of a loss trying to figure out why this doesn’t work on GHA.