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, 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.



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

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

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



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

def definition
  @definition
end

#replacementsObject (readonly)

Returns the value of attribute replacements.



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

def replacements
  @replacements
end

Instance Method Details

#attributesObject



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

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

#logical_idObject



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

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



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

def outputs
  {}
end

#parametersObject



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

def parameters
  {}
end

#permissionObject



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

def permission
  Permission.new(replacements, self)
end

#propertiesObject



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

def properties
  attributes['Properties']
end

#replacerObject



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

def replacer
  Replacer.new(replacements)
end

#standarize(*definition) ⇒ Object

CloudFormation Resources reference: amzn.to/2NKg6ip



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

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

#templateObject



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

def template
  standarize(definition)
end

#typeObject



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

def type
  attributes['Type']
end