Class: Jets::Resource

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/jets/resource/base.rb,
lib/jets/resource.rb,
lib/jets/resource/s3.rb,
lib/jets/resource/function.rb,
lib/jets/resource/replacer.rb,
lib/jets/resource/associated.rb,
lib/jets/resource/permission.rb,
lib/jets/resource/standardizer.rb

Overview

Does not do full expansion, mainly a container that holds the definition and standardizes it without camelizing it.

Defined Under Namespace

Modules: ApiGateway, ChildStack, Config, Events, Iam, Route53, Sns Classes: Associated, Base, Function, Permission, Replacer, S3, Standardizer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition, replacements = {}) ⇒ Resource

Returns a new instance of Resource.



20
21
22
23
# File 'lib/jets/resource.rb', line 20

def initialize(definition, replacements={})
  @definition = definition
  @replacements = replacements
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



19
20
21
# File 'lib/jets/resource.rb', line 19

def definition
  @definition
end

#replacementsObject (readonly)

Returns the value of attribute replacements.



19
20
21
# File 'lib/jets/resource.rb', line 19

def replacements
  @replacements
end

Instance Method Details

#attributesObject



50
51
52
53
54
# File 'lib/jets/resource.rb', line 50

def attributes
  attributes = template.values.first
  attributes = replacer.replace_placeholders(attributes)
  Jets::Camelizer.transform(attributes)
end

#logical_idObject



35
36
37
38
39
40
# File 'lib/jets/resource.rb', line 35

def logical_id
  id = template.keys.first
  # replace possible {namespace} in the logical id
  id = replacer.replace_value(id)
  Jets::Camelizer.camelize(id)
end

#outputsObject



60
61
62
# File 'lib/jets/resource.rb', line 60

def outputs
  {}
end

#parametersObject



56
57
58
# File 'lib/jets/resource.rb', line 56

def parameters
  {}
end

#permissionObject



69
70
71
# File 'lib/jets/resource.rb', line 69

def permission
  Permission.new(replacements, self)
end

#propertiesObject



46
47
48
# File 'lib/jets/resource.rb', line 46

def properties
  attributes['Properties']
end

#replacerObject



64
65
66
# File 'lib/jets/resource.rb', line 64

def replacer
  Replacer.new(replacements)
end

#standarize(*definition) ⇒ Object

CloudFormation Resources reference: amzn.to/2NKg6ip



31
32
33
# File 'lib/jets/resource.rb', line 31

def standarize(*definition)
  Standardizer.new(definition).template
end

#templateObject



25
26
27
# File 'lib/jets/resource.rb', line 25

def template
  standarize(definition)
end

#typeObject



42
43
44
# File 'lib/jets/resource.rb', line 42

def type
  attributes['Type']
end