Sha256: 0a2d9875531abf640113dd9b0933e4617b908f7bbf236f2b6a47d9b3da771f5e

Contents?: true

Size: 1.61 KB

Versions: 34

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::Naming.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

34 entries across 34 versions & 2 rubygems

Version Path
jets-3.2.2 lib/jets/resource/child_stack/api_deployment.rb
jets-3.2.1 lib/jets/resource/child_stack/api_deployment.rb
jets.benforeva-3.0.17.pre.mount.pre.fix lib/jets/resource/child_stack/api_deployment.rb
jets-3.2.0 lib/jets/resource/child_stack/api_deployment.rb
jets-3.1.5 lib/jets/resource/child_stack/api_deployment.rb
jets-3.1.4 lib/jets/resource/child_stack/api_deployment.rb
jets-3.1.3 lib/jets/resource/child_stack/api_deployment.rb
jets-3.1.2 lib/jets/resource/child_stack/api_deployment.rb
jets-3.1.1 lib/jets/resource/child_stack/api_deployment.rb
jets-3.1.0 lib/jets/resource/child_stack/api_deployment.rb
jets-3.0.23 lib/jets/resource/child_stack/api_deployment.rb
jets-3.0.22 lib/jets/resource/child_stack/api_deployment.rb
jets-3.0.21 lib/jets/resource/child_stack/api_deployment.rb
jets-3.0.20 lib/jets/resource/child_stack/api_deployment.rb
jets-3.0.19 lib/jets/resource/child_stack/api_deployment.rb
jets-3.0.18 lib/jets/resource/child_stack/api_deployment.rb
jets-3.0.17 lib/jets/resource/child_stack/api_deployment.rb
jets-3.0.16 lib/jets/resource/child_stack/api_deployment.rb
jets-3.0.15 lib/jets/resource/child_stack/api_deployment.rb
jets-3.0.14 lib/jets/resource/child_stack/api_deployment.rb