Class: Jets::Cfn::Builder::Authorizer
- Includes:
- AwsServices, Interface
- Defined in:
- lib/jets/cfn/builder/authorizer.rb
Instance Method Summary collapse
- #add_api_gateway_parameters ⇒ Object
- #add_cognito_authorizers ⇒ Object
- #add_cognito_outputs ⇒ Object
- #add_outputs ⇒ Object
-
#compose ⇒ Object
interface method.
-
#initialize(path) ⇒ Authorizer
constructor
A new instance of Authorizer.
-
#template_path ⇒ Object
interface method.
Methods included from AwsServices
#apigateway, #aws_lambda, #aws_options, #cfn, #dynamodb, #logs, #s3, #s3_resource, #sns, #sqs, #sts
Methods included from AwsServices::StackStatus
#lookup, #stack_exists?, #stack_in_progress?
Methods included from AwsServices::GlobalMemoist
Methods included from Interface
#add_description, #add_output, #add_parameter, #add_parameters, #add_resource, #add_resources, #add_template_resource, #build, #build?, #template, #text, #write
Methods included from Util::Camelize
Methods inherited from Nested
#add_class_iam_policy, #add_common_parameters, #add_function, #add_function_iam_policy, #add_functions, #build_class_iam_policy?, #depends_on_params, #one_lambda_per_controller, #one_lambda_per_method, #scoped_routes, #validate_function_names!
Constructor Details
#initialize(path) ⇒ Authorizer
Returns a new instance of Authorizer.
6 7 8 9 10 |
# File 'lib/jets/cfn/builder/authorizer.rb', line 6 def initialize(path) @path = path # IE: app/authorizers/main_authorizer.rb @app_class = Jets::Klass.from_path(path) @template = ActiveSupport::HashWithIndifferentAccess.new(Resources: {}) end |
Instance Method Details
#add_api_gateway_parameters ⇒ Object
58 59 60 61 62 |
# File 'lib/jets/cfn/builder/authorizer.rb', line 58 def add_api_gateway_parameters return if Jets::Router.no_routes? add_parameter(:RestApi) end |
#add_cognito_authorizers ⇒ Object
29 30 31 32 33 34 |
# File 'lib/jets/cfn/builder/authorizer.rb', line 29 def @app_class..each do || resource = Jets::Cfn::Resource.new([:definition], [:replacements]) add_resource(resource) end end |
#add_cognito_outputs ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/jets/cfn/builder/authorizer.rb', line 50 def add_cognito_outputs @app_class..each do || resource = Jets::Cfn::Resource.new([:definition], [:replacements]) logical_id = resource.logical_id add_output(logical_id, value: "!Ref #{logical_id}") end end |
#add_outputs ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/jets/cfn/builder/authorizer.rb', line 36 def add_outputs # IE: @app_class = MainAuthorizer # The associated resource is the Jets::Cfn::Resource::ApiGateway::Authorizer definition built during evaluation # of the user defined Authorizer class. We'll use it to compute the logical id. @app_class.definitions.each do |definition| = definition.associated_resources.first next unless resource = Jets::Cfn::Resource.new(.definition, definition.replacements) logical_id = resource.logical_id add_output(logical_id, value: "!Ref #{logical_id}") end end |
#compose ⇒ Object
interface method
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/jets/cfn/builder/authorizer.rb', line 13 def compose add_common_parameters add_api_gateway_parameters add_functions add_resources add_outputs # These dont have lambda functions associated with them add_cognito_outputs end |