boltops-tools / terraspace

Terraspace: The Terraform Framework
https://terraspace.cloud
Apache License 2.0
674 stars 46 forks source link

Terraspace doesn't handle using a local terraform cache #294

Open johnlister opened 1 year ago

johnlister commented 1 year ago

My Environment

Software Version
Operating System WSL
Terraform 1.3.6
Terraspace 2.2.3
Ruby 3.0.3p157

Expected Behaviour

When you run Terraspace with local caching enabled in terraform, it should handle the case whereby a module hasn't been cached and run terraform init in the same way it does when local caching isn't enabled.

Current Behavior

Running Terraspace with local caching enabled in terraform results in a error as any new modules aren't installed and it doesn't automatically trigger terraform init. The following error is produced

Error: Module not installed

on legacy_api.tf line 13: 13: module "aws_api_gateway_rest_api" {

This module's local cache directory could not be read. Run "terraform init" to install all modules required by this configuration.

Step-by-step reproduction instructions

Create a module under the apps folder and reference it in a stack. Enable local terraform caching. Either with an environment variable or add this line to your `.terraformrc` file `plugin_cache_dir = "$HOME/.terraform.cache" ` run terraspace against the stack

-->

Solution Suggestion

Terraspace should handle errors during plan/apply better from terraform in order to trigger the automatic init.