Class: Jets::Cfn::Base

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Includes:
Util::Camelize
Defined in:
lib/jets/cfn/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::Camelize

#camelize

Class Method Details

.truncate_id(id, postfix = '') ⇒ Object



70
71
72
73
74
75
76
77
78
79
# File 'lib/jets/cfn/base.rb', line 70

def truncate_id(id, postfix = '')
  # Api Gateway resource name has a limit of 64 characters.
  # Yet it throws not found when ID is longer than 62 characters and I don't know why.
  # To keep it safe, let's stick to the 62 characters limit.
  if id.size + postfix.size > 62
    "#{id[0..(55 - postfix.size)]}#{Digest::MD5.hexdigest(id)[0..5]}#{postfix}"
  else
    "#{id}#{postfix}"
  end
end

Instance Method Details

#attributesObject



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

def attributes
  attributes = template.values.first
  attributes = replacer.replace_placeholders(attributes)
  camelize(attributes)
end

#logical_idObject



36
37
38
39
40
# File 'lib/jets/cfn/base.rb', line 36

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

#outputsObject



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

def outputs
  {}
end

#parametersObject



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

def parameters
  {}
end

#permissionObject



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

def permission
  Resource::Lambda::Permission.new(replacements, self)
end

#propertiesObject



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

def properties
  attributes[:Properties]
end

#replacementsObject

interface method



17
18
19
# File 'lib/jets/cfn/base.rb', line 17

def replacements
  @replacements || {}
end

#replacerObject



21
22
23
# File 'lib/jets/cfn/base.rb', line 21

def replacer
  Resource::Replacer.new(replacements)
end

#standarize(*definition) ⇒ Object

CloudFormation Resources reference: amzn.to/2NKg6ip



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

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

#templateObject



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

def template
  standarize(definition)
end

#typeObject



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

def type
  attributes[:Type]
end