Dependency errors during undeploy process
Hi, We are working on moving our resources to a new region (region-A) and removing the ones created in the old one (region-B). As part of this process we’re destroying the resources from CLI using terragrunt destroy and then deleting the folders/files and creating a PR and merging it using GW Ref Arch pipeline. Everything was working as expected until we went to remove the sample-app folders, since we had removed other resources used by the sample-app like the load balancers, now we’re getting a dependency error like this one: ``` [ecs-deploy-runner][2022-02-10T11:41:37+0000] [INFO] [infrastructure-deploy-script] 2022-02-10 11:41:37 Successfully checked out origin/master [ecs-deploy-runner][2022-02-10T11:41:37+0000] [INFO] [infrastructure-deploy-script] 2022-02-10 11:41:37 Running command "terragrunt plan -input=false -destroy" [ecs-deploy-runner][2022-02-10T11:41:39+0000] time=2022-02-10T11:41:39Z level=error msg=Could not convert include to the execution context to evaluate additional locals [ecs-deploy-runner][2022-02-10T11:41:39+0000] time=2022-02-10T11:41:39Z level=error msg=Encountered error while evaluating locals. [ecs-deploy-runner][2022-02-10T11:41:39+0000] time=2022-02-10T11:41:39Z level=error msg=Error reading file at path /tmp/tmp9vl1acw3/dev/us-east-2/dev/networking/alb: open /tmp/tmp9vl1acw3/dev/us-east-2/dev/networking/alb: no such file or directory ``` We already deleted these resources from the CLI (`sample-app` and `ecs-cluster`), but now we can’t push the changes to master using the pipeline. Is there are a recommended way to fix this issue? Thanks
The Reference Architecture can be destroyed/undeployed following reverse dependency order, to avoid this issue where existing modules depend on already destroyed resources. Here's an [example undeploy documentation](https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/examples/for-production/infrastructure-live/docs/07-undeploy.md) that you would have received in your Ref Arch deployment (look under /docs). First recommendation, if you still have the code in your version control for the old region (region-B), restore the already deleted module and redeploy. Then undeploy using the reverse dependency order in that undeploy doc. This is a known path. If that's not feasible because there's too many to restore, you can use the [`skip_outputs` flag](https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/) in the `dependency` blocks for the resources that have already been destroyed. Also you'll need to update the `mock_outputs_allowed_terraform_commands` to include `plan` and `apply`. By default we only specify `validate`. If you then run `terragrunt plan -destroy` or `terragrunt apply -destroy`, those dependencies will be ignored and you should be able to complete the destroy. I was able to test this out on a real Ref Arch to confirm this, but please let me know if this doesn't work.