jmccann / drone-terraform

Drone plugin for triggering Terraform deployments
http://plugins.drone.io/jmccann/terraform/
Apache License 2.0
86 stars 93 forks source link

Expose validate command #57

Closed msuterski closed 6 years ago

msuterski commented 7 years ago

Terraform has the validate command that can be run to simply validate the syntax of .tf file.

It would be great to be able to execute it without executing any of the other commands like plan, apply or destroy.

jmccann commented 6 years ago

@msuterski Do you have thoughts on how you would implement this?

I was thinking of making some changes that may require a major release. This would include:

  1. Add validate key and default it to true
  2. Have plan key default to true
  3. Add apply key and default it to true

This would then keep current default behavior to apply if changes found. It would also run all 3 commands by default. Breaking change would be that a "dry run" would require apply: false to be set.

So then the following would validate, plan and apply

pipeline:
  terraform:
    image: jmccann/drone-terraform:latest

The following would "dry run" and validate and plan only:

pipeline:
  terraform:
    image: jmccann/drone-terraform:latest
    apply: false

The following would "validate" only:

pipeline:
  terraform:
    image: jmccann/drone-terraform:latest
    apply: false
    plan: false
msuterski commented 6 years ago

@jmccann I think it should work. I'm a bit worried about apply defaulting to true. It is not now (semi-directly) and might cause problems. The other two are harmless.

I was thinking about exposing something like a command that would be one of them (or more in the future), but that would make it even more backwards incompatible.

jmccann commented 6 years ago

I'll think about your suggestion more and maybe try it out ... I think I may like it better. 😛

jmccann commented 6 years ago

This should be addressed with merge of #58