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

feat: add support for exit code in terraspace validate command #354

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

to-bar
Copy link

@to-bar to-bar commented Aug 22, 2024

This is a πŸ™‹β€β™‚οΈ feature or enhancement.

  • I've added tests (if it's a bug, feature or enhancement)
  • I've adjusted the documentation (if it's a feature or enhancement)
  • [x ] The test suite passes (run bundle exec rspec to verify this)

Summary

terraform validate sets exit code 1 on failed validation, e.g.:

Error: Reference to undeclared input variable

$ echo $?
1

But terraspace not:

$ terraspace validate epi_cluster
=> terraform validate

β”‚ Error: Reference to undeclared input variable

$ echo $?
0

Context

How to Test

  1. Create a project
  2. Break Terraform code, for example by making a typo in a variable name
  3. Run terraspace validate <stack>
  4. Run echo $? to check exit code
  5. Add to config/app.rb:
Terraspace.configure do |config|
  config.all.exit_on_fail.validate = true
end
  1. Run terraspace all validate
  2. Run echo $? to check exit code

Version Changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant