Class: Jets::Cfn::Resource::Nested::Authorizer

Inherits:
Base
  • Object
show all
Defined in:
lib/jets/cfn/resource/nested/authorizer.rb

Instance Method Summary collapse

Methods inherited from Base

#outputs, #template_filename, #template_url

Methods inherited from Base

#attributes, #logical_id, #outputs, #permission, #properties, #replacements, #replacer, #standarize, #template, truncate_id, #type

Methods included from Util::Camelize

#camelize

Constructor Details

#initialize(options = {}) ⇒ Authorizer

Returns a new instance of Authorizer.



3
4
5
6
# File 'lib/jets/cfn/resource/nested/authorizer.rb', line 3

def initialize(options={})
  super
  @path = options[:path]
end

Instance Method Details

#authorizer_logical_idObject

map the path to a camelized logical_id. IE: ProtectAuthorizer



28
29
30
31
32
# File 'lib/jets/cfn/resource/nested/authorizer.rb', line 28

def authorizer_logical_id
  regexp = Regexp.new("#{Jets::Names.templates_folder}/authorizers-")
  authorizer_name = @path.sub(regexp, '').sub('.yml', '')
  authorizer_name.underscore.camelize
end

#definitionObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/jets/cfn/resource/nested/authorizer.rb', line 8

def definition
  logical_id = authorizer_logical_id
  {
    logical_id => {
      Type: "AWS::CloudFormation::Stack",
      Properties: {
        TemplateURL: template_url,
        Parameters: parameters,
      }
    }
  }
end

#parametersObject



21
22
23
24
25
# File 'lib/jets/cfn/resource/nested/authorizer.rb', line 21

def parameters
  params = Jets::Cfn::Params::Common.parameters
  params[:RestApi] = "!GetAtt ApiGateway.Outputs.RestApi"
  params
end