Class: Jets::Resource::ChildStack::ApiResource::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/jets/resource/child_stack/api_resource/page.rb

Overview

Find the ApiResource Page that contains the AWS::ApiGateway::Resource Returns: logical id of ApiResource Page

Class Method Summary collapse

Class Method Details

.logical_id(parameter) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jets/resource/child_stack/api_resource/page.rb', line 5

def self.logical_id(parameter)
  expression = "#{Jets::Naming.template_path_prefix}-api-resources-*"
  # IE: path: #{Jets.build_root}/templates/demo-dev-2-api-resources-1.yml"
  template_paths = Dir.glob(expression).sort.to_a
  found_template = template_paths.detect do |path|
    next unless File.file?(path)

    template = Jets::Cfn::BuiltTemplate.get(path)
    template['Outputs'].keys.include?(parameter)
  end
  md = found_template.match(/-(api-resources-\d+)/)

  md[1].underscore.camelize # IE: ApiResources1
end