I have deployed a project within Terraform. I need to add a 4th application module to my existing plan. How do I update my plan to include this 4th module and deploy the missing module without starting over? I thought terraform import might be an option, but I'm not understanding how it would be done.
1 Answer
Terraform is idempotent so will only change what needs to be changed.
So after applying your existing plan, if you add more modules or resources and run another plan and apply, it will add the new resources not the whole infrastructure.
Terraform import is used when you want to start managing a resource created outside your Terraform code for example created in the AWS console, AWS CLI).
It basically associates and existing resource with your new Terraform code, so that Terraform doesn't try to recreate it when you run the plan/ apply.
-
1
terraform plan -target=module.nifi -target=module.kafka -target=module.other --out test1
and it should calculate the changes required based on the current state. Have you tried this? If so were there any specific errors?-target=module
is not recommended as stated in the docs terraform.io/docs/cli/commands/plan.html#resource-targeting