Skip to content
v2.278.0

ServiceProps Struct ​

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_servicediscovery as servicediscovery } from 'aws-cdk-lib';

declare const namespace: servicediscovery.INamespace;
const serviceProps: servicediscovery.ServiceProps = {
  namespace: namespace,

  // the properties below are optional
  customHealthCheck: {
    failureThreshold: 123,
  },
  description: 'description',
  discoveryType: servicediscovery.DiscoveryType.API,
  dnsRecordType: servicediscovery.DnsRecordType.A,
  dnsTtl: cdk.Duration.minutes(30),
  healthCheck: {
    failureThreshold: 123,
    resourcePath: 'resourcePath',
    type: servicediscovery.HealthCheckType.HTTP,
  },
  loadBalancer: false,
  name: 'name',
  routingPolicy: servicediscovery.RoutingPolicy.WEIGHTED,
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_servicediscovery as servicediscovery

# namespace: servicediscovery.INamespace

service_props = servicediscovery.ServiceProps(
    namespace=namespace,

    # the properties below are optional
    custom_health_check=servicediscovery.HealthCheckCustomConfig(
        failure_threshold=123
    ),
    description="description",
    discovery_type=servicediscovery.DiscoveryType.API,
    dns_record_type=servicediscovery.DnsRecordType.A,
    dns_ttl=cdk.Duration.minutes(30),
    health_check=servicediscovery.HealthCheckConfig(
        failure_threshold=123,
        resource_path="resourcePath",
        type=servicediscovery.HealthCheckType.HTTP
    ),
    load_balancer=False,
    name="name",
    routing_policy=servicediscovery.RoutingPolicy.WEIGHTED
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.servicediscovery.*;

INamespace namespace;

ServiceProps serviceProps = ServiceProps.builder()
        .namespace(namespace)

        // the properties below are optional
        .customHealthCheck(HealthCheckCustomConfig.builder()
                .failureThreshold(123)
                .build())
        .description("description")
        .discoveryType(DiscoveryType.API)
        .dnsRecordType(DnsRecordType.A)
        .dnsTtl(Duration.minutes(30))
        .healthCheck(HealthCheckConfig.builder()
                .failureThreshold(123)
                .resourcePath("resourcePath")
                .type(HealthCheckType.HTTP)
                .build())
        .loadBalancer(false)
        .name("name")
        .routingPolicy(RoutingPolicy.WEIGHTED)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.ServiceDiscovery;

INamespace namespace;

var serviceProps = new ServiceProps {
    Namespace = namespace,

    // the properties below are optional
    CustomHealthCheck = new HealthCheckCustomConfig {
        FailureThreshold = 123
    },
    Description = "description",
    DiscoveryType = DiscoveryType.API,
    DnsRecordType = DnsRecordType.A,
    DnsTtl = Duration.Minutes(30),
    HealthCheck = new HealthCheckConfig {
        FailureThreshold = 123,
        ResourcePath = "resourcePath",
        Type = HealthCheckType.HTTP
    },
    LoadBalancer = false,
    Name = "name",
    RoutingPolicy = RoutingPolicy.WEIGHTED
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var namespace INamespace

serviceProps := &ServiceProps{
	Namespace: namespace,

	// the properties below are optional
	CustomHealthCheck: &HealthCheckCustomConfig{
		FailureThreshold: jsii.Number(123),
	},
	Description: jsii.String("description"),
	DiscoveryType: awscdk.Aws_servicediscovery.DiscoveryType_API,
	DnsRecordType: awscdk.*Aws_servicediscovery.DnsRecordType_A,
	DnsTtl: cdk.Duration_Minutes(jsii.Number(30)),
	HealthCheck: &HealthCheckConfig{
		FailureThreshold: jsii.Number(123),
		ResourcePath: jsii.String("resourcePath"),
		Type: awscdk.*Aws_servicediscovery.HealthCheckType_HTTP,
	},
	LoadBalancer: jsii.Boolean(false),
	Name: jsii.String("name"),
	RoutingPolicy: awscdk.*Aws_servicediscovery.RoutingPolicy_WEIGHTED,
}

Properties ​

customHealthCheckoptionalHealthCheckCustomConfigcustom_health_checkoptionalHealthCheckCustomConfigcustomHealthCheckoptionalHealthCheckCustomConfigCustomHealthCheckoptionalHealthCheckCustomConfigCustomHealthCheckoptionalHealthCheckCustomConfig = 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

descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string = none #
A description of the service.
discoveryTypeoptionalDiscoveryTypediscovery_typeoptionalDiscoveryTypediscoveryTypeoptionalDiscoveryTypeDiscoveryTypeoptionalDiscoveryTypeDiscoveryTypeoptionalDiscoveryType = DNS_AND_API #
Controls how instances within this service can be discovered.
dnsRecordTypeoptionalDnsRecordTypedns_record_typeoptionalDnsRecordTypednsRecordTypeoptionalDnsRecordTypeDnsRecordTypeoptionalDnsRecordTypeDnsRecordTypeoptionalDnsRecordType = 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.

dnsTtloptionalDurationdns_ttloptionalDurationdnsTtloptionalDurationDnsTtloptionalDurationDnsTtloptionalDuration = Duration.minutes(1) #
The amount of time, in seconds, that you want DNS resolvers to cache the settings for this record.
healthCheckoptionalHealthCheckConfighealth_checkoptionalHealthCheckConfighealthCheckoptionalHealthCheckConfigHealthCheckoptionalHealthCheckConfigHealthCheckoptionalHealthCheckConfig = none #
Settings for an optional health check.
notes

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.

loadBalanceroptionalbooleanload_balanceroptionalboolloadBalanceroptionalBooleanLoadBalanceroptionalboolLoadBalanceroptional*bool = false #
Whether or not this service will have an Elastic LoadBalancer registered to it as an AliasTargetInstance.

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

nameoptionalstringnameoptionalstrnameoptionalStringNameoptionalstringNameoptional*string #
A name for the Service.

Default: CloudFormation-generated name

namespaceINamespacenamespaceINamespacenamespaceINamespaceNamespaceINamespaceNamespaceINamespace required #
The namespace that you want to use for DNS configuration.
routingPolicyoptionalRoutingPolicyrouting_policyoptionalRoutingPolicyroutingPolicyoptionalRoutingPolicyRoutingPolicyoptionalRoutingPolicyRoutingPolicyoptionalRoutingPolicy #
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.

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