Service

Provides a Service Discovery Service resource.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var exampleVpc = new Aws.Ec2.Vpc("exampleVpc", new Aws.Ec2.VpcArgs
        {
            CidrBlock = "10.0.0.0/16",
            EnableDnsSupport = true,
            EnableDnsHostnames = true,
        });
        var examplePrivateDnsNamespace = new Aws.ServiceDiscovery.PrivateDnsNamespace("examplePrivateDnsNamespace", new Aws.ServiceDiscovery.PrivateDnsNamespaceArgs
        {
            Description = "example",
            Vpc = exampleVpc.Id,
        });
        var exampleService = new Aws.ServiceDiscovery.Service("exampleService", new Aws.ServiceDiscovery.ServiceArgs
        {
            DnsConfig = new Aws.ServiceDiscovery.Inputs.ServiceDnsConfigArgs
            {
                NamespaceId = examplePrivateDnsNamespace.Id,
                DnsRecords = 
                {
                    new Aws.ServiceDiscovery.Inputs.ServiceDnsConfigDnsRecordArgs
                    {
                        Ttl = 10,
                        Type = "A",
                    },
                },
                RoutingPolicy = "MULTIVALUE",
            },
            HealthCheckCustomConfig = new Aws.ServiceDiscovery.Inputs.ServiceHealthCheckCustomConfigArgs
            {
                FailureThreshold = 1,
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2"
	"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/servicediscovery"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleVpc, err := ec2.NewVpc(ctx, "exampleVpc", &ec2.VpcArgs{
			CidrBlock:          pulumi.String("10.0.0.0/16"),
			EnableDnsSupport:   pulumi.Bool(true),
			EnableDnsHostnames: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		examplePrivateDnsNamespace, err := servicediscovery.NewPrivateDnsNamespace(ctx, "examplePrivateDnsNamespace", &servicediscovery.PrivateDnsNamespaceArgs{
			Description: pulumi.String("example"),
			Vpc:         exampleVpc.ID(),
		})
		if err != nil {
			return err
		}
		_, err = servicediscovery.NewService(ctx, "exampleService", &servicediscovery.ServiceArgs{
			DnsConfig: &servicediscovery.ServiceDnsConfigArgs{
				NamespaceId: examplePrivateDnsNamespace.ID(),
				DnsRecords: servicediscovery.ServiceDnsConfigDnsRecordArray{
					&servicediscovery.ServiceDnsConfigDnsRecordArgs{
						Ttl:  pulumi.Int(10),
						Type: pulumi.String("A"),
					},
				},
				RoutingPolicy: pulumi.String("MULTIVALUE"),
			},
			HealthCheckCustomConfig: &servicediscovery.ServiceHealthCheckCustomConfigArgs{
				FailureThreshold: pulumi.Int(1),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_aws as aws

example_vpc = aws.ec2.Vpc("exampleVpc",
    cidr_block="10.0.0.0/16",
    enable_dns_support=True,
    enable_dns_hostnames=True)
example_private_dns_namespace = aws.servicediscovery.PrivateDnsNamespace("examplePrivateDnsNamespace",
    description="example",
    vpc=example_vpc.id)
example_service = aws.servicediscovery.Service("exampleService",
    dns_config=aws.servicediscovery.ServiceDnsConfigArgs(
        namespace_id=example_private_dns_namespace.id,
        dns_records=[aws.servicediscovery.ServiceDnsConfigDnsRecordArgs(
            ttl=10,
            type="A",
        )],
        routing_policy="MULTIVALUE",
    ),
    health_check_custom_config=aws.servicediscovery.ServiceHealthCheckCustomConfigArgs(
        failure_threshold=1,
    ))
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const exampleVpc = new aws.ec2.Vpc("exampleVpc", {
    cidrBlock: "10.0.0.0/16",
    enableDnsSupport: true,
    enableDnsHostnames: true,
});
const examplePrivateDnsNamespace = new aws.servicediscovery.PrivateDnsNamespace("examplePrivateDnsNamespace", {
    description: "example",
    vpc: exampleVpc.id,
});
const exampleService = new aws.servicediscovery.Service("exampleService", {
    dnsConfig: {
        namespaceId: examplePrivateDnsNamespace.id,
        dnsRecords: [{
            ttl: 10,
            type: "A",
        }],
        routingPolicy: "MULTIVALUE",
    },
    healthCheckCustomConfig: {
        failureThreshold: 1,
    },
});

Create a Service Resource

new Service(name: string, args?: ServiceArgs, opts?: CustomResourceOptions);
@overload
def Service(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            description: Optional[str] = None,
            dns_config: Optional[ServiceDnsConfigArgs] = None,
            health_check_config: Optional[ServiceHealthCheckConfigArgs] = None,
            health_check_custom_config: Optional[ServiceHealthCheckCustomConfigArgs] = None,
            name: Optional[str] = None,
            namespace_id: Optional[str] = None,
            tags: Optional[Mapping[str, str]] = None,
            tags_all: Optional[Mapping[str, str]] = None)
@overload
def Service(resource_name: str,
            args: Optional[ServiceArgs] = None,
            opts: Optional[ResourceOptions] = None)
func NewService(ctx *Context, name string, args *ServiceArgs, opts ...ResourceOption) (*Service, error)
public Service(string name, ServiceArgs? args = null, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args ServiceArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args ServiceArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args ServiceArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args ServiceArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Service Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The Service resource accepts the following input properties:

Description string
The description of the service.
DnsConfig ServiceDnsConfigArgs
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 ServiceHealthCheckConfigArgs
A complex type that contains settings for an optional health check. Only for Public DNS namespaces.
HealthCheckCustomConfig ServiceHealthCheckCustomConfigArgs
A complex type that contains settings for ECS managed health checks.
Name string
The name of the service.
NamespaceId string
The ID of the namespace to use for DNS configuration.
Tags Dictionary<string, string>
A map of tags to assign to the service. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
TagsAll Dictionary<string, string>
A map of tags assigned to the resource, including those inherited from the provider .
Description string
The description of the service.
DnsConfig ServiceDnsConfig
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 ServiceHealthCheckConfig
A complex type that contains settings for an optional health check. Only for Public DNS namespaces.
HealthCheckCustomConfig ServiceHealthCheckCustomConfig
A complex type that contains settings for ECS managed health checks.
Name string
The name of the service.
NamespaceId string
The ID of the namespace to use for DNS configuration.
Tags map[string]string
A map of tags to assign to the service. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
TagsAll map[string]string
A map of tags assigned to the resource, including those inherited from the provider .
description string
The description of the service.
dnsConfig ServiceDnsConfigArgs
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 ServiceHealthCheckConfigArgs
A complex type that contains settings for an optional health check. Only for Public DNS namespaces.
healthCheckCustomConfig ServiceHealthCheckCustomConfigArgs
A complex type that contains settings for ECS managed health checks.
name string
The name of the service.
namespaceId string
The ID of the namespace to use for DNS configuration.
tags {[key: string]: string}
A map of tags to assign to the service. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
tagsAll {[key: string]: string}
A map of tags assigned to the resource, including those inherited from the provider .
description str
The description of the service.
dns_config ServiceDnsConfigArgs
A complex type that contains information about the resource record sets that you want Amazon Route 53 to create when you register an instance.
health_check_config ServiceHealthCheckConfigArgs
A complex type that contains settings for an optional health check. Only for Public DNS namespaces.
health_check_custom_config ServiceHealthCheckCustomConfigArgs
A complex type that contains settings for ECS managed health checks.
name str
The name of the service.
namespace_id str
The ID of the namespace to use for DNS configuration.
tags Mapping[str, str]
A map of tags to assign to the service. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
tags_all Mapping[str, str]
A map of tags assigned to the resource, including those inherited from the provider .

Outputs

All input properties are implicitly available as output properties. Additionally, the Service resource produces the following output properties:

Arn string
The ARN of the service.
Id string
The provider-assigned unique ID for this managed resource.
Arn string
The ARN of the service.
Id string
The provider-assigned unique ID for this managed resource.
arn string
The ARN of the service.
id string
The provider-assigned unique ID for this managed resource.
arn str
The ARN of the service.
id str
The provider-assigned unique ID for this managed resource.

Look up an Existing Service Resource

Get an existing Service resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: ServiceState, opts?: CustomResourceOptions): Service
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        arn: Optional[str] = None,
        description: Optional[str] = None,
        dns_config: Optional[ServiceDnsConfigArgs] = None,
        health_check_config: Optional[ServiceHealthCheckConfigArgs] = None,
        health_check_custom_config: Optional[ServiceHealthCheckCustomConfigArgs] = None,
        name: Optional[str] = None,
        namespace_id: Optional[str] = None,
        tags: Optional[Mapping[str, str]] = None,
        tags_all: Optional[Mapping[str, str]] = None) -> Service
func GetService(ctx *Context, name string, id IDInput, state *ServiceState, opts ...ResourceOption) (*Service, error)
public static Service Get(string name, Input<string> id, ServiceState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Arn string
The ARN of the service.
Description string
The description of the service.
DnsConfig ServiceDnsConfigArgs
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 ServiceHealthCheckConfigArgs
A complex type that contains settings for an optional health check. Only for Public DNS namespaces.
HealthCheckCustomConfig ServiceHealthCheckCustomConfigArgs
A complex type that contains settings for ECS managed health checks.
Name string
The name of the service.
NamespaceId string
The ID of the namespace to use for DNS configuration.
Tags Dictionary<string, string>
A map of tags to assign to the service. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
TagsAll Dictionary<string, string>
A map of tags assigned to the resource, including those inherited from the provider .
Arn string
The ARN of the service.
Description string
The description of the service.
DnsConfig ServiceDnsConfig
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 ServiceHealthCheckConfig
A complex type that contains settings for an optional health check. Only for Public DNS namespaces.
HealthCheckCustomConfig ServiceHealthCheckCustomConfig
A complex type that contains settings for ECS managed health checks.
Name string
The name of the service.
NamespaceId string
The ID of the namespace to use for DNS configuration.
Tags map[string]string
A map of tags to assign to the service. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
TagsAll map[string]string
A map of tags assigned to the resource, including those inherited from the provider .
arn string
The ARN of the service.
description string
The description of the service.
dnsConfig ServiceDnsConfigArgs
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 ServiceHealthCheckConfigArgs
A complex type that contains settings for an optional health check. Only for Public DNS namespaces.
healthCheckCustomConfig ServiceHealthCheckCustomConfigArgs
A complex type that contains settings for ECS managed health checks.
name string
The name of the service.
namespaceId string
The ID of the namespace to use for DNS configuration.
tags {[key: string]: string}
A map of tags to assign to the service. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
tagsAll {[key: string]: string}
A map of tags assigned to the resource, including those inherited from the provider .
arn str
The ARN of the service.
description str
The description of the service.
dns_config ServiceDnsConfigArgs
A complex type that contains information about the resource record sets that you want Amazon Route 53 to create when you register an instance.
health_check_config ServiceHealthCheckConfigArgs
A complex type that contains settings for an optional health check. Only for Public DNS namespaces.
health_check_custom_config ServiceHealthCheckCustomConfigArgs
A complex type that contains settings for ECS managed health checks.
name str
The name of the service.
namespace_id str
The ID of the namespace to use for DNS configuration.
tags Mapping[str, str]
A map of tags to assign to the service. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
tags_all Mapping[str, str]
A map of tags assigned to the resource, including those inherited from the provider .

Supporting Types

ServiceDnsConfig

DnsRecords List<ServiceDnsConfigDnsRecordArgs>
An array that contains one DnsRecord object for each resource record set.
NamespaceId string
The ID of the namespace to use for DNS configuration.
RoutingPolicy string
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 []ServiceDnsConfigDnsRecord
An array that contains one DnsRecord object for each resource record set.
NamespaceId string
The ID of the namespace to use for DNS configuration.
RoutingPolicy string
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 ServiceDnsConfigDnsRecordArgs[]
An array that contains one DnsRecord object for each resource record set.
namespaceId string
The ID of the namespace to use for DNS configuration.
routingPolicy string
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
dns_records Sequence[ServiceDnsConfigDnsRecordArgs]
An array that contains one DnsRecord object for each resource record set.
namespace_id str
The ID of the namespace to use for DNS configuration.
routing_policy str
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

ServiceDnsConfigDnsRecord

Ttl int
The amount of time, in seconds, that you want DNS resolvers to cache the settings for this resource record set.
Type string
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
Ttl int
The amount of time, in seconds, that you want DNS resolvers to cache the settings for this resource record set.
Type string
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
ttl number
The amount of time, in seconds, that you want DNS resolvers to cache the settings for this resource record set.
type string
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
ttl int
The amount of time, in seconds, that you want DNS resolvers to cache the settings for this resource record set.
type str
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

ServiceHealthCheckConfig

FailureThreshold int
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.
ResourcePath string
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 string
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
FailureThreshold int
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.
ResourcePath string
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 string
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
failureThreshold number
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.
resourcePath string
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 string
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
failure_threshold int
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.
resource_path str
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 str
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

ServiceHealthCheckCustomConfig

FailureThreshold int
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.
FailureThreshold int
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.
failureThreshold number
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.
failure_threshold int
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.

Import

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

 $ pulumi import aws:servicediscovery/service:Service example 0123456789

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.