Class: Jets::Cfn::TemplateBuilders::ApiGatewayDeploymentBuilder

Inherits:
Object
  • Object
show all
Includes:
AwsServices, Interface
Defined in:
lib/jets/cfn/template_builders/api_gateway_deployment_builder.rb

Instance Method Summary collapse

Methods included from AwsServices

#cfn, #lambda, #s3, #s3_resource, #stack_exists?, #stack_in_progress?, #sts

Methods included from Interface

#add_output, #add_parameter, #add_resource, #build, #post_process_template, #template, #text

Constructor Details

#initialize(options = {}) ⇒ ApiGatewayDeploymentBuilder

Returns a new instance of ApiGatewayDeploymentBuilder.



6
7
8
9
# File 'lib/jets/cfn/template_builders/api_gateway_deployment_builder.rb', line 6

def initialize(options={})
  @options = options
  @template = ActiveSupport::HashWithIndifferentAccess.new(Resources: {})
end

Instance Method Details

#composeObject

compose is an interface method



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jets/cfn/template_builders/api_gateway_deployment_builder.rb', line 12

def compose
  return if @options[:stack_type] == :minimal

  puts "Building API Gateway Deployment template."
  add_parameter("RestApi", Description: "RestApi")

  map = Jets::Cfn::TemplateMappers::ApiGatewayDeploymentMapper.new(path=nil,s3_bucket=nil)
  add_resource(map.logical_id, "AWS::ApiGateway::Deployment",
    Description: "Version #{map.timestamp} deployed by jets",
    RestApiId: "!Ref RestApi",
    StageName: map.stage_name,
  )

  add_output("RestApiUrl", Value: "!Sub 'https://${RestApi}.execute-api.${AWS::Region}.amazonaws.com/#{map.stage_name}/'")
end

#template_pathObject

template_path is an interface method



29
30
31
# File 'lib/jets/cfn/template_builders/api_gateway_deployment_builder.rb', line 29

def template_path
  Jets::Naming.api_gateway_deployment_template_path
end

#writeObject

do not bother writing a template if routes are empty



34
35
36
# File 'lib/jets/cfn/template_builders/api_gateway_deployment_builder.rb', line 34

def write
  super unless Jets::Router.routes.empty?
end