Class: Jets::Cfn::Builders::AuthorizerBuilder
- Inherits:
-
BaseChildBuilder
- Object
- BaseChildBuilder
- Jets::Cfn::Builders::AuthorizerBuilder
- Includes:
- AwsServices, Interface
- Defined in:
- lib/jets/cfn/builders/authorizer_builder.rb
Instance Method Summary collapse
- #add_api_gateway_parameters ⇒ Object
- #add_cognito_authorizers ⇒ Object
- #add_cognito_outputs ⇒ Object
- #add_outputs ⇒ Object
- #compose ⇒ Object
-
#initialize(path) ⇒ AuthorizerBuilder
constructor
A new instance of AuthorizerBuilder.
- #template_path ⇒ Object
Methods included from AwsServices
#apigateway, #aws_lambda, #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, #post_process_template, #template, #text, #write
Methods inherited from BaseChildBuilder
#add_class_iam_policy, #add_common_parameters, #add_function, #add_function_iam_policy, #add_functions, #depends_on_params
Constructor Details
#initialize(path) ⇒ AuthorizerBuilder
Returns a new instance of AuthorizerBuilder.
11 12 13 14 15 |
# File 'lib/jets/cfn/builders/authorizer_builder.rb', line 11 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
57 58 59 60 61 |
# File 'lib/jets/cfn/builders/authorizer_builder.rb', line 57 def add_api_gateway_parameters return if Jets::Router.routes.empty? add_parameter("RestApi", Description: "RestApi") end |
#add_cognito_authorizers ⇒ Object
28 29 30 31 32 33 |
# File 'lib/jets/cfn/builders/authorizer_builder.rb', line 28 def @app_class..each do || resource = Jets::Resource.new([:definition], [:replacements]) add_resource(resource) end end |
#add_cognito_outputs ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/jets/cfn/builders/authorizer_builder.rb', line 49 def add_cognito_outputs @app_class..each do || resource = Jets::Resource.new([:definition], [:replacements]) logical_id = resource.logical_id add_output(logical_id, value: "!Ref #{logical_id}") end end |
#add_outputs ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/jets/cfn/builders/authorizer_builder.rb', line 35 def add_outputs # IE: @app_class = MainAuthorizer # The associated resource is the Jets::Resource::ApiGateway::Authorizer definition built during evaluation # of the user defined Authorizer class. We'll use it to compute the logical id. @app_class.tasks.each do |task| = task.associated_resources.first next unless resource = Jets::Resource.new(.definition, task.replacements) logical_id = resource.logical_id add_output(logical_id, value: "!Ref #{logical_id}") end end |
#compose ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/jets/cfn/builders/authorizer_builder.rb', line 17 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 |