Move module resources to current config

Hi all,
I’m new to Terraform and am trying to basically merge a module with the current config template without causing a destroy + recreate on the resources that are currently part of the module.
Is there a way to do something like this?

terraform state mv ‘module.module_name’ ‘./’
Or is my only option moving each individual resource under the module?

terraform state mv ‘module.module_name.resource_type.resource_name’ ‘resource_type.resource_name’

Any help would be greatly appreciated.

1 Like

@vladpRiM are you saying you want to essentially move the code out of your modules and just make a larger .tf file?

If that’s the case I would simply try moving the code. Since Terraform is effectively importing the code from the modules this should have no effect on the resources being created. That being said. A Terraform plan should quickly tell you if this method doesn’t work. For simplicity I could copy the code you want out of your module and put it in your current .tf file, then comment out the lines where you have the module being imported. Let us know how it goes!

1 Like

@castironclay yeah, that’s what I’m trying to do.

Tried this already, the plan states it will destroy all module.module_name.* resources and re-create them as resource_type.resource_name .