Class: Chef::Knife::CfnCreate

Inherits:
CfnBase show all
Defined in:
lib/chef/knife/cfn_create.rb

Instance Method Summary collapse

Methods inherited from CfnBase

#connection, included, #is_image_windows?, #locate_config_value, #msg_pair, #validate!

Methods inherited from Chef::Knife

#create_create_def, #create_update_def, #iam_name_from_profile, #ini_parse

Instance Method Details

#runObject



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/chef/knife/cfn_create.rb', line 114

def run
$stdout.sync = true

validate!

stack_name = @name_args[0]

if stack_name.nil?
  show_usage
  ui.error("You must specify a stack name")
  exit 1
end

begin
  response = connection.create_stack(stack_name, create_create_def)
  rescue Excon::Errors::BadRequest => e
    i= e.response.body.index("<Message>")
    j = e.response.body.index("</Message>")
    if !i.nil? and !j.nil?
      ui.error(e.response.body[i+9,j-i-9])
    else
      print "\n#{e.response.body}"
    end
    exit 1
  else
    message = "Stack #{stack_name} creation started"
    print "\n#{ui.color(message, :green)}\n"
  end
end