Class: Chef::Knife::CloudformationValidate

Inherits:
Chef::Knife
  • Object
show all
Includes:
KnifeCloudformation::Knife::Base, KnifeCloudformation::Knife::Template
Defined in:
lib/chef/knife/cloudformation_validate.rb

Overview

Cloudformation validate command

Constant Summary

Constants included from KnifeCloudformation::Knife::Template

KnifeCloudformation::Knife::Template::TEMPLATE_IGNORE_DIRECTORIES

Instance Method Summary collapse

Methods included from KnifeCloudformation::Knife::Template

included

Methods included from KnifeCloudformation::Knife::Base

included

Instance Method Details

#_runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/chef/knife/cloudformation_validate.rb', line 15

def _run
  file = load_template_file
  ui.info "#{ui.color('Cloud Formation Validation: ', :bold)} #{Chef::Config[:knife][:cloudformation][:file].sub(Dir.pwd, '').sub(%r{^/}, '')}"
  file = KnifeCloudformation::Utils::StackParameterScrubber.scrub!(file)
  file = translate_template(file)
  begin
    result = provider.connection.stacks.build(
      :name => 'validation-stack',
      :template => file
    ).validate
    ui.info ui.color('  -> VALID', :bold, :green)
  rescue => e
    ui.info ui.color('  -> INVALID', :bold, :red)
    ui.fatal e.message
    failed = true
  end
end