Module: Cfnlego

Defined in:
lib/cfnlego.rb,
lib/cfnlego/resource.rb,
lib/cfnlego/cloudformation.rb

Overview

Cfnlego

Defined Under Namespace

Classes: CloudFormation, Resource

Class Method Summary collapse

Class Method Details

.fetch_resource_contentObject



20
21
22
# File 'lib/cfnlego.rb', line 20

def self.fetch_resource_content
  File.read(CfnDsl.specification_file)
end

.ResourcesObject



10
11
12
13
14
15
16
17
18
# File 'lib/cfnlego.rb', line 10

def self.Resources
  content = fetch_resource_content
  supported_resources = JSON.parse(content)
  resources = []
  supported_resources['ResourceTypes'].each_key do |resource|
    resources << resource
  end
  resources
end

.run(options) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cfnlego.rb', line 24

def self.run(options)
  # Constructure Resources
  resources = []
  options[:resources].each do |r|
    /(.*),(.*)/.match(r) do |m|
      type = m[1]
      name = m[2]
      resources << Cfnlego::Resource.new(type, name)
    end
  end

  begin
    return Cfnlego::CloudFormation.new(resources).render
  rescue RuntimeError => e
    warn "Error: #{e.message}"
  end
  nil
end