Sha256: 639c788c494bd7c28a451dea3cde4a00f5f99e8fe86bd9817d4a637631cc84f6

Contents?: true

Size: 1.6 KB

Versions: 89

Compression:

Stored size: 1.6 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
      subdomain = Jets.project_namespace
      managed_domain_name = "#{subdomain}.#{Jets.config.domain.hosted_zone_name}"
      name = Jets.config.domain.name || managed_domain_name
      # 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

89 entries across 89 versions & 3 rubygems

Version Path
jets-2.3.11 lib/jets/resource/api_gateway/domain_name.rb
jets-2.3.10 lib/jets/resource/api_gateway/domain_name.rb
jets-2.3.9 lib/jets/resource/api_gateway/domain_name.rb
jets-2.3.8 lib/jets/resource/api_gateway/domain_name.rb
jets-2.3.7 lib/jets/resource/api_gateway/domain_name.rb
jets-2.3.6 lib/jets/resource/api_gateway/domain_name.rb
jets-2.3.5 lib/jets/resource/api_gateway/domain_name.rb
jets-2.3.4 lib/jets/resource/api_gateway/domain_name.rb
jets-2.3.3 lib/jets/resource/api_gateway/domain_name.rb
jets-2.3.2 lib/jets/resource/api_gateway/domain_name.rb
jets-2.3.1 lib/jets/resource/api_gateway/domain_name.rb
jets-2.3.0 lib/jets/resource/api_gateway/domain_name.rb
jets-2.2.5 lib/jets/resource/api_gateway/domain_name.rb
jets-2.2.4 lib/jets/resource/api_gateway/domain_name.rb
jets-2.2.3 lib/jets/resource/api_gateway/domain_name.rb
jets-2.2.2 lib/jets/resource/api_gateway/domain_name.rb
jets-2.2.1 lib/jets/resource/api_gateway/domain_name.rb
jets-2.2.0 lib/jets/resource/api_gateway/domain_name.rb
jets-2.1.7 lib/jets/resource/api_gateway/domain_name.rb
jets-2.1.6 lib/jets/resource/api_gateway/domain_name.rb