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/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, Lambda, Route53, Sns, Sqs Classes: Associated, Base, Permission, Replacer, S3, Standardizer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Resource.



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

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

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



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

def definition
  @definition
end

#replacementsObject (readonly)

Returns the value of attribute replacements.



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

def replacements
  @replacements
end

Instance Method Details

#attributesObject



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

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

#logical_idObject



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

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



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

def outputs
  {}
end

#parametersObject



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

def parameters
  {}
end

#permissionObject



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

def permission
  Permission.new(replacements, self)
end

#propertiesObject



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

def properties
  attributes['Properties']
end

#replacerObject



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

def replacer
  Replacer.new(replacements)
end

#standarize(*definition) ⇒ Object

CloudFormation Resources reference: amzn.to/2NKg6ip



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

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

#templateObject



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

def template
  standarize(definition)
end

#typeObject



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

def type
  attributes['Type']
end