'Terragrunt import with no root main.tf?

I want to run terragrunt import on an external module. (This resource exists in the real world and I want to pull it into my state).

# terragrunt.hcl
terraform {
  source = "../../../../..//modules/environment"
}

inputs = {
  env_list = [
    {
        name = "dev"
    }
  ]
}


# modules/environments/main.tf
resource "confluentcloud_environment" "environment" {
  provider = confluentcloudofficial
  count = length(var.env_list)
  display_name = var.env_list[count.index].name
}

terragrunt import 'confluentcloud_environment.enviroment[0]' env-299n2

is the command I'd use I think (I get this resource name from a terragrunt plan) but I'm left with this error:

Error: resource address "confluentcloud_environment.enviroment[0]" does not exist in the configuration.

Before importing this resource, please create its configuration in the root module. For example:

resource "confluentcloud_environment" "enviroment" { # (resource arguments) }

Is it possible to import existing state into Terraform (via Terragrunt) without first declaring it in a root main.tf?



Solution 1:[1]

Turns out all I needed to do was delete the contents in the .terragrunt-cache folder and try again. 3 days of my life...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alexander Witte