Terragrunt: Terragrunt destroy-all ignore dependencies

Created on 19 Jun 2020  ยท  4Comments  ยท  Source: gruntwork-io/terragrunt

Hi all,

in our config we have a lambda we deploy which needs the IDs of other resources (vpc etc.) which is another repo.

dependencies {
  paths = [
    "../../remote-state-rds", "../../remote-state-vpc"
  ]
}

dependency "remote-state-rds" {
  config_path = "../../remote-state-rds"
}

We used dependency blocks to get the terraform_remote_state of these objects and output it. Works well, but it seems when we call destroy-all, it is trying to also destroy the dependency state. Can this be prevented?

question

Most helpful comment

You can either:

All 4 comments

Would one of these options help?

Also from what I can tell, running xxx-all commands affects the entire dependency-tree. Can you make do with just destroy rather than destroy-all?

I have the same issue, I'm deploying different api gateway stages which depends on an api gateway module. When I delete an stage I don't want to delete the api gateway because it is use by the rest of stages. Using destroy without all is not an option because I have dependencies in each api gateway stage module that indeed I want to delete (vpclink and nlb).

You can either:

I solved it. I wanted to delete the modules inside uat (apigw-vpc-link, nlb, stage-uat, target-attach) without deleting the apigw one.

โ”œโ”€โ”€ apigw
โ”‚   โ”œโ”€โ”€ swagger.yaml
โ”‚   โ”œโ”€โ”€ terraform.tfstate
โ”‚   โ””โ”€โ”€ terragrunt.hcl
โ”œโ”€โ”€ cw-role
โ”‚   โ””โ”€โ”€ terragrunt.hcl
โ”œโ”€โ”€ prod
โ”‚   โ”œโ”€โ”€ apigw-vpc-link
โ”‚   โ”‚   โ””โ”€โ”€ terragrunt.hcl
โ”‚   โ”œโ”€โ”€ nlb
โ”‚   โ”‚   โ””โ”€โ”€ terragrunt.hcl
โ”‚   โ”œโ”€โ”€ stage_proddev
โ”‚   โ”‚   โ””โ”€โ”€ terragrunt.hcl
โ”‚   โ”œโ”€โ”€ stage_prodprm
โ”‚   โ”‚   โ””โ”€โ”€ terragrunt.hcl
โ”‚   โ”œโ”€โ”€ stage_prodstd
โ”‚   โ”‚   โ””โ”€โ”€ terragrunt.hcl
โ”‚   โ””โ”€โ”€ target-attach
โ”‚       โ””โ”€โ”€ terragrunt.hcl
โ””โ”€โ”€ uat
    โ”œโ”€โ”€ apigw-vpc-link
    โ”‚   โ””โ”€โ”€ terragrunt.hcl
    โ”œโ”€โ”€ nlb
    โ”‚   โ””โ”€โ”€ terragrunt.hcl
    โ”œโ”€โ”€ stage-uat
    โ”‚   โ””โ”€โ”€ terragrunt.hcl
    โ””โ”€โ”€ target-attach
        โ””โ”€โ”€ terragrunt.hcl

So this is the command that I employed:

cd uat
terragrunt destroy-all --terragrunt-ignore-external-dependencies

In this way I avoided to delete the apigw module which is an external dependency of my stage-uat module. It would be good to have a clear example in the documentaion for the --terragrunt-ignore-external-dependencies flag, it is quite confusing how to use it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michelzanini picture michelzanini  ยท  3Comments

jtai-omniex picture jtai-omniex  ยท  3Comments

zachwhaley picture zachwhaley  ยท  3Comments

geekifier picture geekifier  ยท  3Comments

shaharmor picture shaharmor  ยท  3Comments