Destroying and re-creating dependent Terraform modules when their parent changes
_A user asked:_ >Hi. We are trying to recreate worker node on calico cni-updates. Is it possible to destroy and recreate the worker node module on parent module changes? ``` module "calico_cni" { source = "../../modules/calico-cni" cluster_kubeconfig = module.control_plane.eks_kubeconfig } module "cluster_workers" { source = "../../modules/cluster-creation/cluster-workers" depends_on = [module.calico_cni] cf_vpc_stack = var.cf_vpc_stack eks_certificate_authority = module.control_plane.eks_cluster_certificate_authority eks_cluster_endpoint = module.control_plane.eks_cluster_endpoint eks_cluster_name = module.control_plane.eks_cluster_name node_group_configurations = var.node_group_configurations workers_ami_id = var.ami_id workers_instance_type = var.instance_type workers_ssm_arn = module.iam_roles.worker_nodes_ssm_policy_arn cluster_kubeconfig = module.control_plane.eks_kubeconfig wait_for_kube_system_timeout = var.wait_for_kube_system_timeout } ```
The best way to achieve this would be to set, for example, a name parameter in your child module (such as the [`worker_name_prefix`](https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/b4fec0f7701f1017cc80226c11790c65bd141f27/modules/services/eks-workers/variables.tf#L207-L211)) in our eks workers module) to the version of CNI - or _something similar that will change everytime that CNI is deployed._ This way, Terraform will consider the name change a destructive and backward incompatible change, causing the dependent resources to be destroyed and re-created as you intend.