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
Instance Method Summary collapse
-
#add_gateway_rest_api ⇒ Object
If the are routes in config/routes.rb add Gateway API in parent stack.
-
#add_gateway_routes ⇒ Object
Adds route related Resources and Outputs.
-
#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
#cfn, #lambda, #logs, #s3, #s3_resource, #stack_exists?, #stack_in_progress?, #sts
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_gateway_rest_api ⇒ Object
If the are routes in config/routes.rb add Gateway API in parent stack
30 31 32 33 34 35 36 37 |
# File 'lib/jets/cfn/builders/api_gateway_builder.rb', line 30 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 add_output("RestApiUrl", Value: deployment.outputs["RestApiUrl"]) end |
#add_gateway_routes ⇒ Object
Adds route related Resources and Outputs
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/jets/cfn/builders/api_gateway_builder.rb', line 40 def add_gateway_routes # The routes required a Gateway Resource to contain them. # TODO: Support more routes. Right now outputing all routes in 1 template will hit the 60 routes limit. # Will have to either output them as a joined string or break this up to multiple templates. # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html # Outputs: Maximum number of outputs that you can declare in your AWS CloudFormation template. 60 outputs # Output name: Maximum size of an output name. 255 characters. # # Note we must use .all_paths, not .routes here because we need to # build the parent ApiGateway::Resource nodes also Jets::Router.all_paths.each do |path| homepage = path == '' next if homepage # handled by RootResourceId output already resource = Jets::Resource::ApiGateway::Resource.new(path) add_resource(resource) add_outputs(resource.outputs) end end |
#compose ⇒ Object
compose is an interface method
12 13 14 15 16 17 |
# File 'lib/jets/cfn/builders/api_gateway_builder.rb', line 12 def compose return if @options[:stack_type] == :minimal add_gateway_rest_api add_gateway_routes end |
#template_path ⇒ Object
template_path is an interface method
20 21 22 |
# File 'lib/jets/cfn/builders/api_gateway_builder.rb', line 20 def template_path Jets::Naming.api_gateway_template_path end |