class Stackit::Template

Attributes

cloudformation[RW]
options[RW]
parsed_parameters[RW]
template_path[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/stackit/template.rb, line 9
def initialize(options = {})
  @cloudformation = options[:cloudformation] || Stackit.cloudformation
  @template_path = options[:template_path]
  @options = {}
end

Public Instance Methods

needs_iam_capability?() click to toggle source
# File lib/stackit/template.rb, line 32
def needs_iam_capability?
  body =~ /AWS::IAM::AccessKey|AWS::IAM::Group|AWS::IAM::InstanceProfile|AWS::IAM::Policy|AWS::IAM::Role|AWS::IAM::User|AWS::IAM::UserToGroupAddition/ ? true : false
end
parse!() click to toggle source
# File lib/stackit/template.rb, line 15
def parse!
  Stackit.logger.info "Parsing cloudformation template: #{template_path}"
  if @template_path =~ /^http/
    @options[:template_url] = @template_path
  else
    @options[:template_body] = body
  end
  @options[:parameters] = validate
  self
end

Private Instance Methods

body() click to toggle source
# File lib/stackit/template.rb, line 38
def body
  path = File.exist?(template_path) ? template_path : File.join(Dir.pwd, template_path)
  raise "Unable to stat filesystem template #{template_path}" if !File.exist?(path)
  File.read(path)
end
validate() click to toggle source
# File lib/stackit/template.rb, line 44
def validate
  cloudformation.validate_template(
    options.slice(:template_body, :template_url)
  )[:parameters]
end