Terraform init bug?

TF v1.0.5

Good morning,

I have configuration that calls a module 3 times as below:

terraform {
  backend "s3" {
    bucket         = "some-bucket"
    key            = "some-key"
    region         = "some-region"
    dynamodb_table = "some-lock-table"
    encrypt        = true
  }
}

provider "aws" {
  region = "some-region"
}

module "b_module" {
  source = "/absolute/local/path/to/same_module"
}

module "a_module" {
  source = "/absolute/local/path/to/same_module"
}

module "c_module" {
  source = "/absolute/local/path/to/same_module"
}

I was noticing that if I modify the local module that only 1 of the 3 modules above were inheriting the change. Through a series of tests I found that a “terraform init” would update the module for 2 of the 3 modules in “.terraform/modules”. The 3rd one (whichever came first alphabetically) would be symbolic linked to the actual local module. This 3rd module was the one that would see changes w/o another init.

Why aren’t all 3 symlinked?

Thank you.

Hi @Kimmel,

The behavior you’ve observed is intended as a performance optimization to avoid re-downloading the same package multiple times. Terraform considers the content of .terraform to be private and so the design doesn’t expect you to modify it directly. The outcome you’ve observed is an implementation detail of the current performance optimization, which could well change in future but we don’t have any current plans to change it.

Good evening @apparentlymart,

I’m not editing anything in .terraform. I’m editing the module at “/absolute/local/path…”. Problem is only one of the 3 copies in “.terraform/modules” is being symlinked. It happens to be the one that comes first alphabetically. The two that aren’t symlinked don’t get updated if I don’t blow away .terraform and re-init.

Thank you for your assistance as always.

Hi @Kimmel,

A module at an absolute filesystem path acts as an external module from Terraform’s perspective. If you want Terraform to consider your child module as belonging to the same module package (and thus not try to “download” the package into the .terraform directory) then you must use relative filesystem paths, in which case Terraform will not create any copies of them in .terraform at all and so you can edit the child module along with its caller.