Sha256: d6c6f470dbe7cd10c07810cf18c55804aa1119dd389347b71fc5dfc0adc86755

Contents?: true

Size: 1.59 KB

Versions: 15

Compression:

Stored size: 1.59 KB

Contents

module Jets::Cfn::Builder::Api
  class Mapping < Base
    # interface method
    def compose
      add_parameters(parameters)
      add_base_path_mapping
    end

    def parameters
      p = {
        GemLayer: "GemLayer",
        IamRole: "IamRole",
        RestApi: "RestApi",
        S3Bucket: "S3Bucket",
      }
      p[:DomainName] = "DomainName" if Jets.custom_domain?
      p[:BasePath] = "BasePath"
      p
    end

    # Because Jets generates a new timestamped logical id for the API Deployment
    # resource it also creates a new root base path mapping and fails.  Additionally,
    # the base path mapping depends on the API Deploy for the stage name.
    #
    # We resolve this by using a custom resource that does an in-place update.
    #
    # Note, also tried to change the domain name of to something like demo-dev-[random].mydomain.com
    # but that does not work because the domain name has to match the route53 record exactly.
    #
    def add_base_path_mapping
      function = Jets::Cfn::Resource::ApiGateway::BasePath::Function.new
      add_resource(function)
      add_outputs(function.outputs)

      mapping = Jets::Cfn::Resource::ApiGateway::BasePath::Mapping.new
      add_resource(mapping)
      add_outputs(mapping.outputs)

      iam_role = Jets::Cfn::Resource::ApiGateway::BasePath::Role.new
      add_resource(iam_role)
      add_outputs(iam_role.outputs)
    end

    # interface method
    def template_path
      Jets::Names.api_mapping_template_path
    end

    # do not write a template unless custom domain is used
    def write
      super if Jets.custom_domain?
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/cfn/builder/api/mapping.rb
jets-5.0.12 lib/jets/cfn/builder/api/mapping.rb
jets-5.0.11 lib/jets/cfn/builder/api/mapping.rb
jets-5.0.10 lib/jets/cfn/builder/api/mapping.rb
jets-5.0.9 lib/jets/cfn/builder/api/mapping.rb
jets-5.0.8 lib/jets/cfn/builder/api/mapping.rb
jets-5.0.7 lib/jets/cfn/builder/api/mapping.rb
jets-5.0.6 lib/jets/cfn/builder/api/mapping.rb
jets-5.0.5 lib/jets/cfn/builder/api/mapping.rb
jets-5.0.4 lib/jets/cfn/builder/api/mapping.rb
jets-5.0.3 lib/jets/cfn/builder/api/mapping.rb
jets-5.0.2 lib/jets/cfn/builder/api/mapping.rb
jets-5.0.1 lib/jets/cfn/builder/api/mapping.rb
jets-5.0.0 lib/jets/cfn/builder/api/mapping.rb
jets-5.0.0.beta1 lib/jets/cfn/builder/api/mapping.rb