-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Terragrunt exclude block is supported only for run-all
#3937
Comments
This is expected, and documented here: Can you give an explanation for why you think this should be the default behavior? The expected usage of the exclude block is to exclude some units from the run queue by default, so that incomplete units can be integrated into a shared codebase and to allow engineers to explicitly test the incomplete units when necessary. |
Because it is offered as a replacement of the |
Did you note the call out in the docs that a terraform {
before_hook "prevent_deploy" {
commands = ["apply", "destroy"]
execute = local.ban_deploy ? ["bash", "-c", "echo 'Deploying on weekends is not allowed. Go home.' && exit 1"] : []
}
} That's a good idea! If you agree that users have access to the tooling that they need without changing the configuration block, please feel free to submit a pull request to update the documentation in a way that would have made the behavior obvious to you when you first looked at it. |
That is way uglier and actually throws an error which it shouldn't be. Will look into a PR. Would that mean that there are no plans to provide the existing |
I can understand a desire to keep things the same, but that behavior of exiting without error was also surprising to users. When including a configuration with a If you have a use-case where you would prefer that the exclude block also exits early for a standalone run, I would like to learn more about it. Knowing that it has value for users in real world scenarios might convince us to change how the |
I understand that the current behavior might be surprising in some cases, especially in CI systems where warnings can be easy to miss. However, from our perspective, skip = true is an intentional decision—it means the configuration is set up correctly and behaving as expected. Introducing an error in this case would create unnecessary failures, making deployments more confusing rather than clearer. In our setup, we maintain a structured set of Terragrunt projects and deploy them across multiple environments for consistency. However, not all projects belong in every environment, so we use a configuration file to define where each project should be deployed. During execution, we check this file and skip the project if it isn't needed in the target environment. Seeing errors in this scenario would be misleading since the process is working exactly as designed. Would you be open to discussing alternative ways to improve visibility in CI while preserving the expected behavior for cases like ours? |
Yes! Let's discuss. It seems like the solution that would work best for most users is to simply not add the unnecessary units in each environment, so as it currently stands, it doesn't seem like good default behavior to have an early exit when performing a run on one unit. Would a design that allowed users to opt in for an exclude to exit early instead of just excluding the unit from the run queue help? Alternatively, maybe it would serve users better to have a configuration for the I'd also like to understand better why it wouldn't be an error for a user to try to perform a run in a unit that shouldn't be used for a particular environment. Why is it better to exit with a status code of zero? |
In our use case we have a monorepository with hundreds of projects. Each project has a configuration file that has the following yaml: environments:
- dev
- prod We use the same
That is why a project might be only in dev for example and it needs to be skipped in prod. On the suggestions, both seems like an option. We will be okay if it is not the default behavior but have the possibility to configure it. From my experience, the current |
I see. That seems like a good use-case for early exit even when running directly on the unit. e.g.
In your use-case, though, wouldn't you prefer that an engineer get a non-zero exit code when they try to run the unit directly? That's bad behavior, right? If a user does |
Will have a discussion with the team around it. Maybe its just a bias because I am used to the current solution. What worries me more is that the hooks are executed multiple times, once per dependency. I remember having really bad time around destroys and hooks. That is why I was hyped about the exclude block attribute to exclude dependencies but ... :) |
I can understand being frustrated when existing patterns change, especially if you feel like you're losing access to features. We're trying to get to a stable configuration before 1.0 so we can make backwards compatibility guarantees going forward. |
Describe the bug
The
skip
attribute is deprecated and the documentation says it should be replaced with anexclude
block. However, theexclude
block does not provide the same functionality. It seems like it is honoured only onrun-all
commands and not during regularplan
orapply
commands.Steps To Reproduce
The following works:
This doesn't:
A regular plan is executed even though the requirement is not satisfied.
Expected behavior
A clear and concise description of what you expected to happen.
Nice to haves
Versions
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: