Sha256: fece27de086e6578e4823417be6e0d21d160dc33bff0da96a0a185c0139aa8e6

Contents?: true

Size: 1.61 KB

Versions: 13

Compression:

Stored size: 1.61 KB

Contents

# Implements:
#
#   definition
#   template_filename
#
module Jets::Resource::ChildStack
  class ApiDeployment < Base
    def definition
      {
        deployment_id => {
          type: "AWS::CloudFormation::Stack",
          properties: {
            template_url: template_url,
            parameters: parameters,
          },
          depends_on: depends_on,
        }
      }
    end

    def parameters
      p = {
        GemLayer: "!Ref GemLayer",
        IamRole: "!GetAtt IamRole.Arn",
        RestApi: "!GetAtt ApiGateway.Outputs.RestApi",
        S3Bucket: "!Ref S3Bucket",
      }
      p[:DomainName] = "!GetAtt ApiGateway.Outputs.DomainName" if Jets.custom_domain?
      p[:BasePath] = Jets.config.domain.base_path unless Jets.config.domain.base_path.nil?
      p
    end

    def depends_on
      expression = "#{Jets::Names.template_path_prefix}-*_controller*"
      controller_logical_ids = []
      Dir.glob(expression).each do |path|
        next unless File.file?(path)

        # map the path to a camelized logical_id. Example:
        #   /tmp/jets/demo/templates/demo-dev-2-posts_controller.yml to
        #   PostsController
        regexp = Regexp.new(".*#{Jets.config.project_namespace}-app-")
        controller_name = path.sub(regexp, '').sub('.yml', '')
        controller_logical_id = controller_name.underscore.camelize
        controller_logical_ids << controller_logical_id
      end
      controller_logical_ids
    end

    def deployment_id
      Jets::Resource::ApiGateway::Deployment.logical_id
    end

    def template_filename
      "#{Jets.config.project_namespace}-api-deployment.yml"
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
jets-4.0.12 lib/jets/resource/child_stack/api_deployment.rb
jets-4.0.11 lib/jets/resource/child_stack/api_deployment.rb
jets-4.0.10 lib/jets/resource/child_stack/api_deployment.rb
jets-4.0.9 lib/jets/resource/child_stack/api_deployment.rb
jets-4.0.8 lib/jets/resource/child_stack/api_deployment.rb
jets-4.0.7 lib/jets/resource/child_stack/api_deployment.rb
jets-4.0.6 lib/jets/resource/child_stack/api_deployment.rb
jets-4.0.5 lib/jets/resource/child_stack/api_deployment.rb
jets-4.0.4 lib/jets/resource/child_stack/api_deployment.rb
jets-4.0.3 lib/jets/resource/child_stack/api_deployment.rb
jets-4.0.2 lib/jets/resource/child_stack/api_deployment.rb
jets-4.0.1 lib/jets/resource/child_stack/api_deployment.rb
jets-4.0.0 lib/jets/resource/child_stack/api_deployment.rb