question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Run 'terraform get'" on all external modules

See original GitHub issue

Prerequisites

  • Ensure you have latest version of plugin installed
  • Search for possible issue duplicates

Installation details

  • IDE version (Help->About->Copy to Clipboard): RubyMine 2018.2.3
  • intellij-hcl plugin version (Settings->Plugins): 0.6.12
  • Terraform version (terraform -v): 0.11.8

Terraform Configuration Files

module "vpc" {
  source                            = "terraform-aws-modules/vpc/aws"
  name                              = "${var.customer}-${var.application}-${var.env}-vpc"
  cidr                              = "${var.cidr}"

  azs                               = ["${data.aws_availability_zones.available.names}"]
  private_subnets                   = ["${var.private_subnets}"]
  public_subnets                    = ["${var.public_subnets}"]
  database_subnets                  = ["${var.database_subnets}"]

  enable_nat_gateway                = true
  single_nat_gateway                = true

  tags = {
    Terraform   = true
    Client      = "${var.customer}"
    Application = "${var.application}"
    Environment = "${var.env}"
  }
}

Exception

Expected Behavior

No terraform errors

Actual Behavior

Can't locate module locally: No .terraform found under project directory, please run `terraform get` in appropriate place more... (⌘F1)

Steps to Reproduce

  1. rm -fr .terraform
  2. terraform init
  3. open a .tf file that contains a “source” to a module that is loaded from an external source, such as the Terraform registry (see the VPC module) or Git(Hub)
  4. terraform get
  5. goto 3.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:14
  • Comments:32 (8 by maintainers)

github_iconTop GitHub Comments

7reactions
c33scommented, May 2, 2019

upgraded to 0.6.14 but still have the error.

terrafrom code:

module "foo" {
  source = "git::ssh://git@gitlab.com/example/terraform/modules/foo.git?ref=master"
  count = "${terraform.workspace == "production" ? 1 : 0}"
}

Can’t locate module locally: Terraform Module ‘foo’ with source ‘git::ssh://git@gitlab.com/example/terraform/modules/foo.git?ref=master’ directory not found locally, use 'terraform get` to fetch modules

4reactions
matschaffercommented, Jan 23, 2020

I ran into this on 0.7.7 & terraform 0.12 as well. Then noticed this in the logs

2020-01-23 15:20:42,512 [  31127]   WARN - nfig.model.ModuleDetectionUtil - File PsiDirectory:/Users/mat/safecast/infrastructure/terraform/common is not under project root
2020-01-23 15:20:42,512 [  31127]   WARN - nfig.model.ModuleDetectionUtil - No .terraform found under project directory, please run `terraform get` in appropriate place
2020-01-23 15:20:42,512 [  31127]   WARN - nfig.model.ModuleDetectionUtil - Terraform Module 'map_test' with source 'github.com/riboseinc/terraform-aws-s3-cloudfront-website' directory not found locally, use `terraform get` to fetch modules.

If I switch around my file paths so that my terraform files are under my project root, things seem to work.

Here’s the before/after filesystem tree to hopefully provide better context

Previous structure:

./safecast/safecastapi [project root]
./safecast/infrastructure [imported as generic module]
./safecast/infrastructure/terraform

New structure:

./safecast/api [project root]
./safecast/api/safecastapi [ruby module]
./safecast/api/infrastructure [just a directory under "api" project root]
./safecast/api/infrastructure/terraform
Read more comments on GitHub >

github_iconTop Results From Across the Web

Execute Terraform commands on multiple modules at once
Execute Terraform commands on multiple modules at once. Motivation. The run-all command. Passing outputs between modules. Dependencies between modules.
Read more >
Module Sources | Terraform - HashiCorp Developer
Terraform installs modules from Git repositories by running git clone , and so it will respect any local Git configuration set on your...
Read more >
Terraform: cannot locate module locally: unknown reason
Basically, all of my external modules that should be fetched by get are unknown regardless of whether I perform terraform get or not....
Read more >
The Ultimate Guide on How to Write Terraform Modules - Part 1
Add a new variable named module_depends_on to the module's variables.tf file. The type of the variable is set to any to mimic the...
Read more >
Invicton-Labs/shell-resource/external - Terraform Registry
This module allows generic shell commands to be run as a resource (will only re-run when an input variable changes). It supports both...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found