Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependencies block is not ordering when running run-all #3033

Closed
1 of 2 tasks
iomarcovalente opened this issue Mar 27, 2024 · 1 comment
Closed
1 of 2 tasks

Dependencies block is not ordering when running run-all #3033

iomarcovalente opened this issue Mar 27, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@iomarcovalente
Copy link

iomarcovalente commented Mar 27, 2024

Describe the bug
As per title, when using dependency and dependencies block external dependencies are not applied in order but rather in a random order - first-come first serve I suspect

To Reproduce
Have a terragrunt module that calls two other modules as dependencies:

dependency "account_context" {
  enabled = local.dependencies_info.account_context.enabled
  config_path  = local.dependencies_info.account_context.path
  mock_outputs = include.aws.locals.mocks.locals.map.account_context
}

dependency "kms" {
  enabled = local.dependencies_info.kms.enabled
  config_path  = local.dependencies_info.kms.path
  mock_outputs = include.aws.locals.mocks.locals.map.kms
}

dependencies {
  paths = [
    local.dependencies_info.account_context.path,
    local.dependencies_info.kms.path
  ]
}

locals {
  dependencies_info = {
    account_context = {
      enabled = true
      path = "${get_path_to_repo_root()}/aws/services/account-context"
    }
    kms = {
      enabled = true
      path = "${get_path_to_repo_root()}/aws/services/kms"
    }
}

Terminal output:

# M1: ~/Documents/git/terragrunt-config/aws/services/keyspaces
ζ terragrunt run-all apply
Module: 		 ~/Documents/git/terragrunt-config/aws/services/keyspaces
External dependency: 	 ~/Documents/git/terragrunt-config/aws/services/account-context
Should Terragrunt apply the external dependency? (y/n) ^C

# M1: ~/Documents/git/terragrunt-config/aws/services/keyspaces
ζ terragrunt run-all apply
Module: 		 ~/Documents/git/terragrunt-config/aws/services/keyspaces
External dependency: 	 ~/Documents/git/terragrunt-config/aws/services/account-context
Should Terragrunt apply the external dependency? (y/n) ^C

# M1: ~/Documents/git/terragrunt-config/aws/services/keyspaces
ζ terragrunt run-all apply
Module: 		 ~/Documents/git/terragrunt-config/aws/services/keyspaces
External dependency: 	 ~/Documents/git/terragrunt-config/aws/services/account-context
Should Terragrunt apply the external dependency? (y/n) ^C

# M1: ~/Documents/git/terragrunt-config/aws/services/keyspaces
ζ terragrunt run-all apply
Module: 		 ~/Documents/git/terragrunt-config/aws/services/keyspaces
External dependency: 	 ~/Documents/git/terragrunt-config/aws/services/kms
Should Terragrunt apply the external dependency? (y/n) ^C

# M1: ~/Documents/git/terragrunt-config/aws/services/keyspaces
ζ terragrunt run-all apply
Module: 		 ~/Documents/git/terragrunt-config/aws/services/keyspaces
External dependency: 	 ~/Documents/git/terragrunt-config/aws/services/kms 
Should Terragrunt apply the external dependency? (y/n) ^C

# M1: ~/Documents/git/terragrunt-config/aws/services/keyspaces
ζ terragrunt run-all apply
Module: 		 ~/Documents/git/terragrunt-config/aws/services/keyspaces
External dependency: 	 ~/Documents/git/terragrunt-config/aws/services/account-context
Should Terragrunt apply the external dependency? (y/n) ^C

As shown above in the multiple run attempts, the order in terragrunt.hcl file dependencies block is not honoured: we get an inconsistent behaviour on each run

Expected behavior
Dependencies block order in the dependencies path attribute array to be honoured.

It isn't very clear to be fair what the example in the docs is trying to say with:

# When applying this terragrunt config in an `run-all` command, make sure the modules at "../vpc" and "../rds" are
# handled first.
dependencies {
  paths = ["../vpc", "../rds"]
}

But I can only assume that the purpose is to determine the order for terragrunt to apply the dependencies: as per the docs :

the dependencies block (...) is purely for ordering the operations

Otherwise the dependencies block would be pretty useless - unless I am missing something.

Nice to have

  • Terminal output
  • Screenshots

Versions

  • Terragrunt version: terragrunt version 0.54.22
  • Terraform version: Terraform v1.5.6
  • Environment details (Ubuntu 20.04, Windows 10, etc.): darwin_arm64
    Additional context
    Add any other context about the problem here.
@iomarcovalente iomarcovalente added the bug Something isn't working label Mar 27, 2024
@iomarcovalente
Copy link
Author

Update:
After creating a graph as described here
I could see that the services would be deployed in the correct order - based on the graph output, which I believe is the ultimate source of truth here and the cli output just happens to be not accurate.

Happy to close this based on the findings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant