Class: Jets::Cfn::Builders::ApiGatewayBuilder
- Inherits:
-
Object
- Object
- Jets::Cfn::Builders::ApiGatewayBuilder
- Includes:
- AwsServices, Interface
- Defined in:
- lib/jets/cfn/builders/api_gateway_builder.rb
Constant Summary collapse
- PAGE_LIMIT =
Adds route related Resources and Outputs Delegates to ApiResourcesBuilder
Integer(ENV['JETS_AWS_OUTPUTS_LIMIT'] || 60)
Instance Method Summary collapse
- #add_custom_domain ⇒ Object
- #add_domain_name ⇒ Object
-
#add_gateway_rest_api ⇒ Object
If the are routes in config/routes.rb add Gateway API in parent stack.
- #add_gateway_routes ⇒ Object
- #add_route53_dns ⇒ Object
-
#compose ⇒ Object
compose is an interface method.
-
#initialize(options = {}) ⇒ ApiGatewayBuilder
constructor
A new instance of ApiGatewayBuilder.
-
#template_path ⇒ Object
template_path is an interface method.
-
#write ⇒ Object
do not bother writing a template if routes are empty.
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_output, #add_outputs, #add_parameter, #add_parameters, #add_resource, #add_resources, #add_template_resource, #build, #post_process_template, #template, #text
Constructor Details
#initialize(options = {}) ⇒ ApiGatewayBuilder
Returns a new instance of ApiGatewayBuilder.
6 7 8 9 |
# File 'lib/jets/cfn/builders/api_gateway_builder.rb', line 6 def initialize(={}) @options = @template = ActiveSupport::HashWithIndifferentAccess.new(Resources: {}) end |
Instance Method Details
#add_custom_domain ⇒ Object
39 40 41 42 43 |
# File 'lib/jets/cfn/builders/api_gateway_builder.rb', line 39 def add_custom_domain return unless Jets.custom_domain? add_domain_name add_route53_dns if Jets.config.domain.route53 end |
#add_domain_name ⇒ Object
45 46 47 48 49 |
# File 'lib/jets/cfn/builders/api_gateway_builder.rb', line 45 def add_domain_name domain_name = Jets::Resource::ApiGateway::DomainName.new add_resource(domain_name) add_outputs(domain_name.outputs) end |
#add_gateway_rest_api ⇒ Object
If the are routes in config/routes.rb add Gateway API in parent stack
29 30 31 32 33 34 35 36 37 |
# File 'lib/jets/cfn/builders/api_gateway_builder.rb', line 29 def add_gateway_rest_api rest_api = Jets::Resource::ApiGateway::RestApi.new add_resource(rest_api) add_outputs(rest_api.outputs) deployment = Jets::Resource::ApiGateway::Deployment.new outputs = deployment.outputs(true) add_output("RestApiUrl", Value: outputs["RestApiUrl"]) end |
#add_gateway_routes ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/jets/cfn/builders/api_gateway_builder.rb', line 60 def add_gateway_routes # Reject homepage. Otherwise we have 60 - 1 resources on the first page. # There's a next call in ApiResources.add_gateway_resources to skip the homepage. all_paths = Jets::Router.all_paths.reject { |p| p == '' } all_paths.each_slice(PAGE_LIMIT).each_with_index do |paths, i| ApiResourcesBuilder.new(@options, paths, i+1).build end end |
#add_route53_dns ⇒ Object
51 52 53 54 55 |
# File 'lib/jets/cfn/builders/api_gateway_builder.rb', line 51 def add_route53_dns dns = Jets::Resource::Route53::RecordSet.new add_resource(dns) add_outputs(dns.outputs) end |
#compose ⇒ Object
compose is an interface method
12 13 14 15 16 |
# File 'lib/jets/cfn/builders/api_gateway_builder.rb', line 12 def compose add_gateway_routes # "child template": build before add_gateway_rest_api. RestApi logical id and change detection is dependent on it. add_gateway_rest_api # changes parent template add_custom_domain # changes parent template end |
#template_path ⇒ Object
template_path is an interface method
19 20 21 |
# File 'lib/jets/cfn/builders/api_gateway_builder.rb', line 19 def template_path Jets::Naming.api_gateway_template_path end |