Sha256: 425b41d2342b1b575ec339d254902a72a9c49c104d6a937110fdceb168778c96

Contents?: true

Size: 1.72 KB

Versions: 55

Compression:

Stored size: 1.72 KB

Contents

# CloudFormation Docs AWS::ApiGateway::DomainName: https://amzn.to/2Bsnmbq
#
# Example:
#
#   MyDomainName:
#     Type: 'AWS::ApiGateway::DomainName'
#     Properties:
#       DomainName: api.mydomain.com
#       CertificateArn: arn:aws:acm:us-east-1:111122223333:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3
#
module Jets::Resource::ApiGateway
  class DomainName < Jets::Resource::Base
    def definition
      properties = {
        domain_name: domain_name,
        endpoint_configuration: {
          types: endpoint_types
        }
      }
      # Can really only be REGIONAL or EDGE
      if endpoint_types.include?("REGIONAL")
        properties[:regional_certificate_arn] = cert_arn
      end
      if endpoint_types.include?("EDGE")
        properties[:certificate_arn] = cert_arn
      end

      {
        domain_name: {
          type: "AWS::ApiGateway::DomainName",
          properties: properties
        }
      }
    end

    def outputs
      {
        "DomainName" => "!Ref DomainName",
      }
    end

    def domain_name
      name = Jets.config.domain.name
      if Jets.config.domain.apex
        name ||= Jets.config.domain.hosted_zone_name
      else
        subdomain = Jets.project_namespace
        managed_domain_name = "#{subdomain}.#{Jets.config.domain.hosted_zone_name}"
        name ||= managed_domain_name
      end

      # Strip trailing period if there is one set accidentally or else get this error
      #   Trailing period should be omitted from domain name (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException
      name.sub(/\.$/,'')
    end

    def endpoint_types
      [Jets.config.domain.endpoint_type].flatten
    end

    def cert_arn
      Jets.config.domain.cert_arn
    end
  end
end

Version data entries

55 entries across 55 versions & 2 rubygems

Version Path
jets-4.0.12 lib/jets/resource/api_gateway/domain_name.rb
jets-4.0.11 lib/jets/resource/api_gateway/domain_name.rb
jets-4.0.10 lib/jets/resource/api_gateway/domain_name.rb
jets-4.0.9 lib/jets/resource/api_gateway/domain_name.rb
jets-4.0.8 lib/jets/resource/api_gateway/domain_name.rb
jets-4.0.7 lib/jets/resource/api_gateway/domain_name.rb
jets-4.0.6 lib/jets/resource/api_gateway/domain_name.rb
jets-4.0.5 lib/jets/resource/api_gateway/domain_name.rb
jets-4.0.4 lib/jets/resource/api_gateway/domain_name.rb
jets-4.0.3 lib/jets/resource/api_gateway/domain_name.rb
jets-4.0.2 lib/jets/resource/api_gateway/domain_name.rb
jets-4.0.1 lib/jets/resource/api_gateway/domain_name.rb
jets-4.0.0 lib/jets/resource/api_gateway/domain_name.rb
jets-3.2.2 lib/jets/resource/api_gateway/domain_name.rb
jets-3.2.1 lib/jets/resource/api_gateway/domain_name.rb
jets.benforeva-3.0.17.pre.mount.pre.fix lib/jets/resource/api_gateway/domain_name.rb
jets-3.2.0 lib/jets/resource/api_gateway/domain_name.rb
jets-3.1.5 lib/jets/resource/api_gateway/domain_name.rb
jets-3.1.4 lib/jets/resource/api_gateway/domain_name.rb
jets-3.1.3 lib/jets/resource/api_gateway/domain_name.rb