class RubyTerraform::Commands::Validate

Wraps the +terraform validate+ command which checks whether a configuration is valid.

Validates the configuration files in a directory, referring only to the configuration and not accessing any remote services such as remote state, provider APIs, etc.

Validate runs checks that verify whether a configuration is syntactically valid and internally consistent, regardless of any provided variables or existing state. It is thus primarily useful for general verification of reusable modules, including correctness of attribute names and value types.

It is safe to run this command automatically, for example as a post-save check in a text editor or as a test step for a re-usable module in a CI system.

Validation requires an initialized working directory with any referenced plugins and modules installed. To initialize a working directory for validation without accessing any configured remote backend, use the {Init} command passing :backend as false.

To verify configuration in the context of a particular run (a particular target workspace, input variable values, etc), use the {Plan} command instead, which includes an implied validation check.

For options accepted on construction, see {#initialize}.

When executing an instance of {Validate} via {#execute}, the following options are supported:

@example Basic Invocation

RubyTerraform::Commands::Validate.new.execute(
  directory: 'infra/networking')

Public Instance Methods

arguments(parameters) click to toggle source

@!visibility private

# File lib/ruby_terraform/commands/validate.rb, line 71
def arguments(parameters)
  [parameters[:directory]]
end
options() click to toggle source

@!visibility private

Calls superclass method RubyTerraform::Options::Global#options
# File lib/ruby_terraform/commands/validate.rb, line 63
def options
  %w[
    -json
    -no-color
  ] + super
end
subcommands() click to toggle source

@!visibility private

# File lib/ruby_terraform/commands/validate.rb, line 58
def subcommands
  %w[validate]
end