Skip to content

Commit

Permalink
fix: check if tfvars file exists only if when it's expected (#16)
Browse files Browse the repository at this point in the history
## what

- If tfvars are not enabled, we should not check this file in
precondition.

## why

- Bug.

## references

- N/A


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced flexibility in stack configuration by allowing stacks to
proceed without requiring a `.tfvars` file if not enabled.
- Improved handling of various stack configurations, including
`administrative`, `after_apply`, and `before_init`.

- **Bug Fixes**
- Refined conditions for the creation of stack resources based on
integration and drift detection settings.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
gberenice authored Dec 19, 2024
1 parent 9eb3cd4 commit 72c5a77
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ resource "spacelift_stack" "default" {
lifecycle {
# Expected `tfvars` file exists
precondition {
condition = fileexists("${local.configs[each.key].project_root}/tfvars/${local.configs[each.key].tfvars_file_name}.tfvars")
condition = try(local.configs[each.key].tfvars.enabled, true) ? fileexists("${local.configs[each.key].project_root}/tfvars/${local.configs[each.key].tfvars_file_name}.tfvars") : true
error_message = <<-EOT
The required .tfvars file is missing for stack "${each.key}".
Expand Down

0 comments on commit 72c5a77

Please sign in to comment.