Class: Jets::Resource::ApiGateway::DomainName

Inherits:
Base
  • Object
show all
Defined in:
lib/jets/resource/api_gateway/domain_name.rb

Instance Method Summary collapse

Methods inherited from Base

#replacements, #resource

Instance Method Details

#cert_arnObject



55
56
57
# File 'lib/jets/resource/api_gateway/domain_name.rb', line 55

def cert_arn
  Jets.config.domain.cert_arn
end

#definitionObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jets/resource/api_gateway/domain_name.rb', line 13

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

#domain_nameObject



42
43
44
45
46
47
48
49
# File 'lib/jets/resource/api_gateway/domain_name.rb', line 42

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

#endpoint_typesObject



51
52
53
# File 'lib/jets/resource/api_gateway/domain_name.rb', line 51

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

#outputsObject



36
37
38
39
40
# File 'lib/jets/resource/api_gateway/domain_name.rb', line 36

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