Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(stale) modules & providers remain installed after terraform init #30005

Open
radeksimko opened this issue Nov 23, 2021 · 1 comment
Open

(stale) modules & providers remain installed after terraform init #30005

radeksimko opened this issue Nov 23, 2021 · 1 comment
Labels
bug new new issue not yet triaged v1.0 Issues (primarily bugs) reported against v1.0 releases

Comments

@radeksimko
Copy link
Member

radeksimko commented Nov 23, 2021

Terraform Version

v1.0.11

Terraform Configuration Files

module "name" {
  source = "./local"
  foo    = "blah"
}

# To be commented out or removed
module "eks" {
  source = "terraform-aws-modules/eks/aws"

  cluster_version = "1.21"
  cluster_name    = "my-cluster"
  vpc_id          = "vpc-1234556abcdef"
  subnets         = ["subnet-abcde012", "subnet-bcde012a", "subnet-fghi345a"]

  worker_groups = [
    {
      instance_type = "m4.large"
      asg_max_size  = 5
    }
  ]
}

Expected Behavior

Previously installed removed module (eks in the example above) to be removed from the module manifest and filesystem (assuming it's downloaded from a remote location) upon removal from the configuration and running get or init.

Actual Behavior

Entry for the removed module stays in the manifest and remains cached on the filesystem.

.terraform/modules/modules.json

{
    "Modules": [
        {
            "Key": "",
            "Source": "",
            "Dir": "."
        },
        {
            "Key": "eks",
            "Source": "terraform-aws-modules/eks/aws",
            "Version": "17.24.0",
            "Dir": ".terraform/modules/eks"
        },
        {
            "Key": "eks.fargate",
            "Source": "./modules/fargate",
            "Dir": ".terraform/modules/eks/modules/fargate"
        },
        {
            "Key": "eks.node_groups",
            "Source": "./modules/node_groups",
            "Dir": ".terraform/modules/eks/modules/node_groups"
        },
        {
            "Key": "name",
            "Source": "./local",
            "Dir": "local"
        }
    ]
}
$ du -h -s .terraform/modules/eks
2.1M	.terraform/modules/eks

Steps to Reproduce

  1. terraform get
  2. remove whole module "eks" block
  3. terraform get

Additional Context

We leverage the internal state (acknowledging it's not a stable/public API) in .terraform/modules to display details about installed modules in the Terraform VS Code extension and we noticed that we may often present stale data as a result of the above.

2021-11-23 09 48 21

@radeksimko radeksimko added bug new new issue not yet triaged labels Nov 23, 2021
@radeksimko
Copy link
Member Author

After thinking through this and typing it all out 🦆 I'm realizing we could and should probably use the configuration as a primary source of truth in our use case and then use the internal state as secondary to provide the hierarchy, installed version, installed path etc.

So it's no longer a blocker for us, but it is still somewhat surprising behaviour for me, so I'm going to leave this open in case you want to address it. I would expect this behaviour to potentially be problematic from disk usage perspective over the long run.

btw. the same problem applies to provider installation.

@radeksimko radeksimko changed the title (stale) modules remain installed after terraform get/init (stale) modules & providers remain installed after terraform init Jul 27, 2022
@apparentlymart apparentlymart added the v1.0 Issues (primarily bugs) reported against v1.0 releases label Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug new new issue not yet triaged v1.0 Issues (primarily bugs) reported against v1.0 releases
Projects
None yet
Development

No branches or pull requests

2 participants