Remote backend issue from terraspace 1.0.0 and later

Hi, we’ve been using Terraspace since 0.6.x, and its been great. However, in our efforts to upgrade to 1.x, we have discovered that our use of custom cache directory is not compatible with terraspace 1.0.x and remote backends (TF Cloud). We use AWS and the “terraspace_plugin_aws” 0.3.6.
Our app.rb has the customization:

class CustomBuildDir
  def call(mod)
    ":CACHE_ROOT/:NAMESPACE/:REGION/:ENV/:BUILD_DIR" # String is returned
  end
end
Terraspace.configure do |config|
  config.logger.level = :info
  config.test_framework = "rspec"
  config.build.cache_dir = CustomBuildDir
...

When the build is executed by terraspace (i.e. terraspace build etc.) the directory name within .terraspace-cache is not “expanded”, i.e. it has the namespace expander var, :NAMESPACE/dev/stacks/lambda. And the AWS Account expansion ERB calls also don’t work. We’ve localized this behavior to the config/terraform/backend.tf file… We use remote backends to operate with Terraform Cloud. IF we change the “remote” keyword back to “s3”, everything works great. So is “remote” backends with expansion no longer supportable?

terraform {
  backend "remote" {
    organization = "<%= ENV['TFC_ORG'] %>" 
    workspaces {
      name = "<%= expansion('my-engine-:MOD_NAME-:ENV-:REGION-:ACCOUNT') %>"
    }
  }
}

Bummer. It was a bug introduced in 1.0 as a part of on-prem support being added. Thanks for the report. Fixed in this PR:

Also added a config.autodetect.expander option: https://terraspace.cloud/docs/config/reference/

Though you shouldn’t have to use it. It should just work after you upgrade to terraspace 1.0.6

Hi Tung,
Wow! Thank you… updated to 1.0.6, and the remote backend is now working normally. THANK YOU.

1 Like