feat: only run apply when plan detects changes
This commit is contained in:
@@ -25,6 +25,19 @@ plan: init
|
||||
@$(call vault_env) && \
|
||||
terragrunt run --all --parallelism 4 --non-interactive plan
|
||||
|
||||
apply-if-changes: init
|
||||
@$(call vault_env) && \
|
||||
terragrunt run --all --parallelism 4 --non-interactive plan -- -detailed-exitcode -out=tfplan; \
|
||||
EXIT_CODE=$$?; \
|
||||
if [ $$EXIT_CODE -eq 2 ]; then \
|
||||
$(call vault_env) && \
|
||||
terragrunt run --all --parallelism 2 --non-interactive apply -- tfplan; \
|
||||
elif [ $$EXIT_CODE -eq 0 ]; then \
|
||||
echo "No changes detected, skipping apply."; \
|
||||
else \
|
||||
exit $$EXIT_CODE; \
|
||||
fi
|
||||
|
||||
apply: init
|
||||
@$(call vault_env) && \
|
||||
terragrunt run --all --parallelism 2 --non-interactive apply
|
||||
|
||||
Reference in New Issue
Block a user