Class: AWSCDK::ServiceDiscovery::DNSServiceProps

Inherits:
BaseServiceProps
  • Object
show all
Defined in:
service_discovery/dns_service_props.rb

Overview

Service props needed to create a service in a given namespace.

Used by createService() for PrivateDnsNamespace and PublicDnsNamespace

Direct Known Subclasses

ServiceProps

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(custom_health_check: nil, description: nil, health_check: nil, name: nil, discovery_type: nil, dns_record_type: nil, dns_ttl: nil, load_balancer: nil, routing_policy: nil) ⇒ DNSServiceProps

Returns a new instance of DNSServiceProps.

Parameters:

  • custom_health_check (AWSCDK::ServiceDiscovery::HealthCheckCustomConfig, nil) (defaults to: nil)

    Structure containing failure threshold for a custom health checker.

  • description (String, nil) (defaults to: nil)

    A description of the service.

  • health_check (AWSCDK::ServiceDiscovery::HealthCheckConfig, nil) (defaults to: nil)

    Settings for an optional health check.

  • name (String, nil) (defaults to: nil)

    A name for the Service.

  • discovery_type (AWSCDK::ServiceDiscovery::DiscoveryType, nil) (defaults to: nil)

    Controls how instances within this service can be discovered.

  • dns_record_type (AWSCDK::ServiceDiscovery::DNSRecordType, nil) (defaults to: nil)

    The DNS type of the record that you want AWS Cloud Map to create.

  • dns_ttl (AWSCDK::Duration, nil) (defaults to: nil)

    The amount of time, in seconds, that you want DNS resolvers to cache the settings for this record.

  • load_balancer (Boolean, nil) (defaults to: nil)

    Whether or not this service will have an Elastic LoadBalancer registered to it as an AliasTargetInstance.

  • routing_policy (AWSCDK::ServiceDiscovery::RoutingPolicy, nil) (defaults to: nil)

    The routing policy that you want to apply to all DNS records that AWS Cloud Map creates when you register an instance and specify this service.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'service_discovery/dns_service_props.rb', line 19

def initialize(custom_health_check: nil, description: nil, health_check: nil, name: nil, discovery_type: nil, dns_record_type: nil, dns_ttl: nil, load_balancer: nil, routing_policy: nil)
  @custom_health_check = custom_health_check.is_a?(Hash) ? ::AWSCDK::ServiceDiscovery::HealthCheckCustomConfig.new(**custom_health_check.transform_keys(&:to_sym)) : custom_health_check
  Jsii::Type.check_type(@custom_health_check, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3Nfc2VydmljZWRpc2NvdmVyeS5IZWFsdGhDaGVja0N1c3RvbUNvbmZpZyJ9")), "customHealthCheck") unless @custom_health_check.nil?
  @description = description
  Jsii::Type.check_type(@description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description") unless @description.nil?
  @health_check = health_check.is_a?(Hash) ? ::AWSCDK::ServiceDiscovery::HealthCheckConfig.new(**health_check.transform_keys(&:to_sym)) : health_check
  Jsii::Type.check_type(@health_check, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3Nfc2VydmljZWRpc2NvdmVyeS5IZWFsdGhDaGVja0NvbmZpZyJ9")), "healthCheck") unless @health_check.nil?
  @name = name
  Jsii::Type.check_type(@name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "name") unless @name.nil?
  @discovery_type = discovery_type
  Jsii::Type.check_type(@discovery_type, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3Nfc2VydmljZWRpc2NvdmVyeS5EaXNjb3ZlcnlUeXBlIn0=")), "discoveryType") unless @discovery_type.nil?
  @dns_record_type = dns_record_type
  Jsii::Type.check_type(@dns_record_type, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3Nfc2VydmljZWRpc2NvdmVyeS5EbnNSZWNvcmRUeXBlIn0=")), "dnsRecordType") unless @dns_record_type.nil?
  @dns_ttl = dns_ttl
  Jsii::Type.check_type(@dns_ttl, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "dnsTtl") unless @dns_ttl.nil?
  @load_balancer = load_balancer
  Jsii::Type.check_type(@load_balancer, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "loadBalancer") unless @load_balancer.nil?
  @routing_policy = routing_policy
  Jsii::Type.check_type(@routing_policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3Nfc2VydmljZWRpc2NvdmVyeS5Sb3V0aW5nUG9saWN5In0=")), "routingPolicy") unless @routing_policy.nil?
end

Instance Attribute Details

#custom_health_checkAWSCDK::ServiceDiscovery::HealthCheckCustomConfig? (readonly)

Note:

Default: none

Structure containing failure threshold for a custom health checker.

Only one of healthCheckConfig or healthCheckCustomConfig can be specified. See: https://docs.aws.amazon.com/cloud-map/latest/api/API_HealthCheckCustomConfig.html



47
48
49
# File 'service_discovery/dns_service_props.rb', line 47

def custom_health_check
  @custom_health_check
end

#descriptionString? (readonly)

Note:

Default: none

A description of the service.

Returns:

  • (String, nil)


52
53
54
# File 'service_discovery/dns_service_props.rb', line 52

def description
  @description
end

#discovery_typeAWSCDK::ServiceDiscovery::DiscoveryType? (readonly)

Note:

Default: DNS_AND_API

Controls how instances within this service can be discovered.



72
73
74
# File 'service_discovery/dns_service_props.rb', line 72

def discovery_type
  @discovery_type
end

#dns_record_typeAWSCDK::ServiceDiscovery::DNSRecordType? (readonly)

Note:

Default: A

The DNS type of the record that you want AWS Cloud Map to create.

Supported record types include A, AAAA, A and AAAA (A_AAAA), CNAME, and SRV.



80
81
82
# File 'service_discovery/dns_service_props.rb', line 80

def dns_record_type
  @dns_record_type
end

#dns_ttlAWSCDK::Duration? (readonly)

Note:

Default: Duration.minutes(1)

The amount of time, in seconds, that you want DNS resolvers to cache the settings for this record.

Returns:



85
86
87
# File 'service_discovery/dns_service_props.rb', line 85

def dns_ttl
  @dns_ttl
end

#health_checkAWSCDK::ServiceDiscovery::HealthCheckConfig? (readonly)

Note:

Default: none

Settings for an optional health check.

If you specify health check settings, AWS Cloud Map associates the health check with the records that you specify in DnsConfig. Only one of healthCheckConfig or healthCheckCustomConfig can be specified. Not valid for PrivateDnsNamespaces. If you use healthCheck, you can only register IP instances to this service.



62
63
64
# File 'service_discovery/dns_service_props.rb', line 62

def health_check
  @health_check
end

#load_balancerBoolean? (readonly)

Note:

Default: false

Whether or not this service will have an Elastic LoadBalancer registered to it as an AliasTargetInstance.

Setting this to true correctly configures the routing_policy and performs some additional validation.

Returns:

  • (Boolean, nil)


93
94
95
# File 'service_discovery/dns_service_props.rb', line 93

def load_balancer
  @load_balancer
end

#nameString? (readonly)

Note:

Default: CloudFormation-generated name

A name for the Service.

Returns:

  • (String, nil)


67
68
69
# File 'service_discovery/dns_service_props.rb', line 67

def name
  @name
end

#routing_policyAWSCDK::ServiceDiscovery::RoutingPolicy? (readonly)

Note:

Default: WEIGHTED for CNAME records and when loadBalancer is true, MULTIVALUE otherwise

The routing policy that you want to apply to all DNS records that AWS Cloud Map creates when you register an instance and specify this service.



98
99
100
# File 'service_discovery/dns_service_props.rb', line 98

def routing_policy
  @routing_policy
end

Class Method Details

.jsii_propertiesObject



100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'service_discovery/dns_service_props.rb', line 100

def self.jsii_properties
  {
    :custom_health_check => "customHealthCheck",
    :description => "description",
    :health_check => "healthCheck",
    :name => "name",
    :discovery_type => "discoveryType",
    :dns_record_type => "dnsRecordType",
    :dns_ttl => "dnsTtl",
    :load_balancer => "loadBalancer",
    :routing_policy => "routingPolicy",
  }
end

Instance Method Details

#to_jsiiObject



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'service_discovery/dns_service_props.rb', line 114

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "customHealthCheck" => @custom_health_check,
    "description" => @description,
    "healthCheck" => @health_check,
    "name" => @name,
    "discoveryType" => @discovery_type,
    "dnsRecordType" => @dns_record_type,
    "dnsTtl" => @dns_ttl,
    "loadBalancer" => @load_balancer,
    "routingPolicy" => @routing_policy,
  })
  result.compact
end