Skip to content

Resource: awsServiceDiscoveryService

Provides a Service Discovery Service resource.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsVpcExample = new aws.vpc.Vpc(this, "example", {
  cidrBlock: "10.0.0.0/16",
  enableDnsHostnames: true,
  enableDnsSupport: true,
});
const awsServiceDiscoveryPrivateDnsNamespaceExample =
  new aws.serviceDiscoveryPrivateDnsNamespace.ServiceDiscoveryPrivateDnsNamespace(
    this,
    "example_1",
    {
      description: "example",
      name: "example.terraform.local",
      vpc: awsVpcExample.id,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsServiceDiscoveryPrivateDnsNamespaceExample.overrideLogicalId("example");
const awsServiceDiscoveryServiceExample =
  new aws.serviceDiscoveryService.ServiceDiscoveryService(this, "example_2", {
    dnsConfig: {
      dnsRecords: [
        {
          ttl: 10,
          type: "A",
        },
      ],
      namespaceId: awsServiceDiscoveryPrivateDnsNamespaceExample.id,
      routingPolicy: "MULTIVALUE",
    },
    healthCheckCustomConfig: {
      failureThreshold: 1,
    },
    name: "example",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsServiceDiscoveryServiceExample.overrideLogicalId("example");
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsServiceDiscoveryPublicDnsNamespaceExample =
  new aws.serviceDiscoveryPublicDnsNamespace.ServiceDiscoveryPublicDnsNamespace(
    this,
    "example",
    {
      description: "example",
      name: "example.terraform.com",
    }
  );
const awsServiceDiscoveryServiceExample =
  new aws.serviceDiscoveryService.ServiceDiscoveryService(this, "example_1", {
    dnsConfig: {
      dnsRecords: [
        {
          ttl: 10,
          type: "A",
        },
      ],
      namespaceId: awsServiceDiscoveryPublicDnsNamespaceExample.id,
    },
    healthCheckConfig: {
      failureThreshold: 10,
      resourcePath: "path",
      type: "HTTP",
    },
    name: "example",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsServiceDiscoveryServiceExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required, ForceNew) The name of the service.
  • description - (Optional) The description of the service.
  • dnsConfig - (Optional) A complex type that contains information about the resource record sets that you want Amazon Route 53 to create when you register an instance.
  • healthCheckConfig - (Optional) A complex type that contains settings for an optional health check. Only for Public DNS namespaces.
  • forceDestroy - (Optional, Default:false ) A boolean that indicates all instances should be deleted from the service so that the service can be destroyed without error. These instances are not recoverable.
  • healthCheckCustomConfig - (Optional, ForceNew) A complex type that contains settings for ECS managed health checks.
  • namespaceId - (Optional) The ID of the namespace that you want to use to create the service.
  • type - (Optional) If present, specifies that the service instances are only discoverable using the discoverInstances API operation. No DNS records is registered for the service instances. The only valid value is http.
  • tags - (Optional) A map of tags to assign to the service. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

dnsConfig

The following arguments are supported:

  • namespaceId - (Required, ForceNew) The ID of the namespace to use for DNS configuration.
  • dnsRecords - (Required) An array that contains one DnsRecord object for each resource record set.
  • routingPolicy - (Optional) The routing policy that you want to apply to all records that Route 53 creates when you register an instance and specify the service. Valid Values: MULTIVALUE, WEIGHTED

dnsRecords

The following arguments are supported:

  • ttl - (Required) The amount of time, in seconds, that you want DNS resolvers to cache the settings for this resource record set.
  • type - (Required, ForceNew) The type of the resource, which indicates the value that Amazon Route 53 returns in response to DNS queries. Valid Values: A, AAAA, SRV, CNAME

healthCheckConfig

The following arguments are supported:

  • failureThreshold - (Optional) The number of consecutive health checks. Maximum value of 10.
  • resourcePath - (Optional) The path that you want Route 53 to request when performing health checks. Route 53 automatically adds the DNS name for the service. If you don't specify a value, the default value is /.
  • type - (Optional, ForceNew) The type of health check that you want to create, which indicates how Route 53 determines whether an endpoint is healthy. Valid Values: HTTP, HTTPS, TCP

healthCheckCustomConfig

The following arguments are supported:

  • failureThreshold - (Optional, ForceNew) The number of 30-second intervals that you want service discovery to wait before it changes the health status of a service instance. Maximum value of 10.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The ID of the service.
  • arn - The ARN of the service.
  • tagsAll - A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.

Import

Service Discovery Service can be imported using the service ID, e.g.,

$ terraform import aws_service_discovery_service.example 0123456789