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

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

Instance Method Summary collapse

Methods inherited from Base

#attributes, #logical_id, #parameters, #permission, #properties, #replacements, #replacer, #standarize, #template, truncate_id, #type

Methods included from Util::Camelize

#camelize

Instance Method Details

#cert_arnObject



61
62
63
# File 'lib/jets/cfn/resource/api_gateway/domain_name.rb', line 61

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/cfn/resource/api_gateway/domain_name.rb', line 13

def definition
  properties = {
    DomainName: domain_name,
    EndpointConfiguration: {
      Types: endpoint_types
    }
  }
  # Can really only be REGIONAL or EDGE
  if endpoint_types.include?("REGIONAL")
    properties[:RegionalCertificateArn] = cert_arn
  end
  if endpoint_types.include?("EDGE")
    properties[:CertificateArn] = cert_arn
  end

  {
    DomainName: {
      Type: "AWS::ApiGateway::DomainName",
      Properties: properties
    }
  }
end

#domain_nameObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/jets/cfn/resource/api_gateway/domain_name.rb', line 42

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

#endpoint_typesObject



57
58
59
# File 'lib/jets/cfn/resource/api_gateway/domain_name.rb', line 57

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

#outputsObject



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

def outputs
  {
    DomainName: "!Ref DomainName",
  }
end