Unable to run terraspace plan with modules

I am attempting to run terraspace plan in a stack that references a module, the output looks good when I run terraspace init, it successful fetches the module however when I run terraspace plan I get an error that the module isn’t installed.

Below is my output:

**$** AWS_REGION=eu-west-1 TS_ENV=new-schema terraspace init sqs
Building .terraspace-cache/eu-west-1/new-schema/stacks/sqs
Built in .terraspace-cache/eu-west-1/new-schema/stacks/sqs
Current directory: .terraspace-cache/eu-west-1/new-schema/stacks/sqs
=> terraform init -get -input=false
**Initializing modules...**
- mailer-queue in ../../modules/sqs
- verification-status-queue in ../../modules/sqs
**Initializing the backend...**
**Initializing provider plugins...**
- Reusing previous version of hashicorp/aws from the dependency lock file
- Using previously-installed hashicorp/aws v4.3.0
**Terraform has been successfully initialized!**
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
**at** **MacBook-Pro-2** **in** **~/GolandProjects/tf** **on** **master** **[+!?$]**
**$** AWS_REGION=eu-west-1 TS_ENV=new-schema terraspace plan sqs
Building .terraspace-cache/eu-west-1/new-schema/stacks/sqs
Built in .terraspace-cache/eu-west-1/new-schema/stacks/sqs
Current directory: .terraspace-cache/eu-west-1/new-schema/stacks/sqs
=> terraform plan -input=false
╷
│ **Error:** **Module not installed**
│
│ on main.tf line 1:
│ 1: module "verification-status-queue" {
  │
│ This module's local cache directory could not be read. Run "terraform
│ init" to install all modules required by this configuration.
╵
╷
│ **Error:** **Module not installed**
│
│ on main.tf line 6:
│ 6: module "mailer-queue" {
│
│ This module's local cache directory could not be read. Run "terraform
│ init" to install all modules required by this configuration.
╵
Error running command: terraform plan -input=false

Is there an extra step I need to install modules within the Terraspace modules folder?

Naw. There shouldn’t be an extra step. :thinking:

Thinking give one of the Getting Started Guides a try.

https://terraspace.cloud/docs/learn/aws/review-project/

It generates an example that uses a module. And it doesn’t require any extra steps.

I had to run terraform get within the stack using the module and now terraspace plan runs correctly :tada:

Thanks!

I am also seeing the same issue with 2.2.15.
There is nothing really special but just can’t figure out what’s causing the problem.

app → modules → common-tags

locals {
  tags = {
    ManagedBy    = "terraform"
    Environment  = "<%= expansion(':ENV') %>"
    Stack        = "<%= expansion(':MOD_NAME') %>"
    Region       = var.organisation
    Organisation = var.organisation
    Project      = var.project_name
  }
}

app → stacks → common-tags

module "common_tags" {
  source = "../../modules/common-tags"

  environment  = var.environment
  project_name = var.project_name
}

terraspace build es

Building .terraspace-cache/westeurope/dev/stacks/es
Created .terraspace-cache/westeurope/dev/modules/common-tags/main.tf
Created .terraspace-cache/westeurope/dev/modules/common-tags/outputs.tf
Created .terraspace-cache/westeurope/dev/modules/common-tags/variables.tf
Terraspace::Builder::Children @queue [common-tags]
Created .terraspace-cache/westeurope/dev/stacks/common-tags/backend.tf
Created .terraspace-cache/westeurope/dev/stacks/common-tags/provider.tf
Created .terraspace-cache/westeurope/dev/stacks/common-tags/main.tf
Created .terraspace-cache/westeurope/dev/stacks/common-tags/outputs.tf
Created .terraspace-cache/westeurope/dev/stacks/common-tags/variables.tf
Layers for common-tags:
    app/stacks/common-tags/tfvars/base.tfvars
Created .terraspace-cache/westeurope/dev/stacks/common-tags/1-base.auto.tfvars
Created .terraspace-cache/westeurope/dev/stacks/es/backend.tf
Created .terraspace-cache/westeurope/dev/stacks/es/provider.tf
Created .terraspace-cache/westeurope/dev/stacks/es/main.tf
Created .terraspace-cache/westeurope/dev/stacks/es/variables.tf
Layers for es:
    app/stacks/es/tfvars/base.tfvars
    app/stacks/es/tfvars/dev.tfvars
    config/stacks/es/tfvars/dev.tfvars
Downloading tfstate files for dependencies defined in tfvars...
Downloading tfstate for stack: common-tags
=> cd /XXX/terraspace-elk-infra/.terraspace-cache/westeurope/dev/stacks/common-tags && terraform state pull > /tmp/terraspace/remote_state/stacks/common-tags/state.json
╷
│ Error: Module not installed
│ 
│   on /XXX/terraspace-elk-infra/.terraspace-cache/westeurope/dev/stacks/common-tags/main.tf line 1:
│    1: module "common_tags" {
│ 
│ This module is not yet installed. Run "terraform init" to install all modules required by this configuration.
╵

Error running: cd /XXX/terraspace-elk-infra/.terraspace-cache/westeurope/dev/stacks/common-tags && terraform state pull > /tmp/terraspace/remote_state/stacks/common-tags/state.json
Please fix the error before continuing
DEBUG: (Output tags could not be looked up for the es tfvars file. common-tags stack needs to be deployed)
Created .terraspace-cache/westeurope/dev/stacks/es/1-base.auto.tfvars
Created .terraspace-cache/westeurope/dev/stacks/es/2-dev.auto.tfvars
Created .terraspace-cache/westeurope/dev/stacks/es/3-dev.auto.tfvars
Built in .terraspace-cache/westeurope/dev/stacks/es

❯ tree -d .

.
├── app
│   ├── modules
│   │   └── common-tags
│   └── stacks
│       ├── common-tags
│       │   └── tfvars
│       └── es
│           └── tfvars
├── config
│   ├── envs
│   ├── stacks
│   │   └── es
│   │       └── tfvars
│   └── terraform
└── log

Small update:
If I run terraspace up es then everything works as expected. I suppose that terraspace build es is not initializing the TF modules