1. Packages
  2. Consul Provider
  3. API Docs
  4. Service
Consul v3.12.4 published on Wednesday, Feb 12, 2025 by Pulumi

consul.Service

Explore with Pulumi AI

A high-level resource for creating a Service in Consul in the Consul catalog. This is appropriate for registering external services and can be used to create services addressable by Consul that cannot be registered with a local agent.

NOTE: If a Consul agent is running on the node where this service is registered, it is not recommended to use this resource as the service will be removed during the next anti-entropy synchronization.

Example Usage

Creating a new node with the service:

import * as pulumi from "@pulumi/pulumi";
import * as consul from "@pulumi/consul";

const compute = new consul.Node("compute", {
    name: "compute-google",
    address: "www.google.com",
});
const google = new consul.Service("google", {
    name: "google",
    node: compute.name,
    port: 80,
    tags: ["tag0"],
});
Copy
import pulumi
import pulumi_consul as consul

compute = consul.Node("compute",
    name="compute-google",
    address="www.google.com")
google = consul.Service("google",
    name="google",
    node=compute.name,
    port=80,
    tags=["tag0"])
Copy
package main

import (
	"github.com/pulumi/pulumi-consul/sdk/v3/go/consul"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		compute, err := consul.NewNode(ctx, "compute", &consul.NodeArgs{
			Name:    pulumi.String("compute-google"),
			Address: pulumi.String("www.google.com"),
		})
		if err != nil {
			return err
		}
		_, err = consul.NewService(ctx, "google", &consul.ServiceArgs{
			Name: pulumi.String("google"),
			Node: compute.Name,
			Port: pulumi.Int(80),
			Tags: pulumi.StringArray{
				pulumi.String("tag0"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Consul = Pulumi.Consul;

return await Deployment.RunAsync(() => 
{
    var compute = new Consul.Node("compute", new()
    {
        Name = "compute-google",
        Address = "www.google.com",
    });

    var google = new Consul.Service("google", new()
    {
        Name = "google",
        Node = compute.Name,
        Port = 80,
        Tags = new[]
        {
            "tag0",
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.consul.Node;
import com.pulumi.consul.NodeArgs;
import com.pulumi.consul.Service;
import com.pulumi.consul.ServiceArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var compute = new Node("compute", NodeArgs.builder()
            .name("compute-google")
            .address("www.google.com")
            .build());

        var google = new Service("google", ServiceArgs.builder()
            .name("google")
            .node(compute.name())
            .port(80)
            .tags("tag0")
            .build());

    }
}
Copy
resources:
  google:
    type: consul:Service
    properties:
      name: google
      node: ${compute.name}
      port: 80
      tags:
        - tag0
  compute:
    type: consul:Node
    properties:
      name: compute-google
      address: www.google.com
Copy

Utilizing an existing known node:

import * as pulumi from "@pulumi/pulumi";
import * as consul from "@pulumi/consul";

const google = new consul.Service("google", {
    name: "google",
    node: "google",
    port: 443,
});
Copy
import pulumi
import pulumi_consul as consul

google = consul.Service("google",
    name="google",
    node="google",
    port=443)
Copy
package main

import (
	"github.com/pulumi/pulumi-consul/sdk/v3/go/consul"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := consul.NewService(ctx, "google", &consul.ServiceArgs{
			Name: pulumi.String("google"),
			Node: pulumi.String("google"),
			Port: pulumi.Int(443),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Consul = Pulumi.Consul;

return await Deployment.RunAsync(() => 
{
    var google = new Consul.Service("google", new()
    {
        Name = "google",
        Node = "google",
        Port = 443,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.consul.Service;
import com.pulumi.consul.ServiceArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var google = new Service("google", ServiceArgs.builder()
            .name("google")
            .node("google")
            .port(443)
            .build());

    }
}
Copy
resources:
  google:
    type: consul:Service
    properties:
      name: google
      node: google
      port: 443
Copy

Register a health-check:

import * as pulumi from "@pulumi/pulumi";
import * as consul from "@pulumi/consul";

const redis = new consul.Service("redis", {
    name: "redis",
    node: "redis",
    port: 6379,
    checks: [{
        checkId: "service:redis1",
        name: "Redis health check",
        status: "passing",
        http: "https://www.hashicorptest.com",
        tlsSkipVerify: false,
        method: "PUT",
        interval: "5s",
        timeout: "1s",
        deregisterCriticalServiceAfter: "30s",
        headers: [
            {
                name: "foo",
                values: ["test"],
            },
            {
                name: "bar",
                values: ["test"],
            },
        ],
    }],
});
Copy
import pulumi
import pulumi_consul as consul

redis = consul.Service("redis",
    name="redis",
    node="redis",
    port=6379,
    checks=[{
        "check_id": "service:redis1",
        "name": "Redis health check",
        "status": "passing",
        "http": "https://www.hashicorptest.com",
        "tls_skip_verify": False,
        "method": "PUT",
        "interval": "5s",
        "timeout": "1s",
        "deregister_critical_service_after": "30s",
        "headers": [
            {
                "name": "foo",
                "values": ["test"],
            },
            {
                "name": "bar",
                "values": ["test"],
            },
        ],
    }])
Copy
package main

import (
	"github.com/pulumi/pulumi-consul/sdk/v3/go/consul"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := consul.NewService(ctx, "redis", &consul.ServiceArgs{
			Name: pulumi.String("redis"),
			Node: pulumi.String("redis"),
			Port: pulumi.Int(6379),
			Checks: consul.ServiceCheckArray{
				&consul.ServiceCheckArgs{
					CheckId:                        pulumi.String("service:redis1"),
					Name:                           pulumi.String("Redis health check"),
					Status:                         pulumi.String("passing"),
					Http:                           pulumi.String("https://www.hashicorptest.com"),
					TlsSkipVerify:                  pulumi.Bool(false),
					Method:                         pulumi.String("PUT"),
					Interval:                       pulumi.String("5s"),
					Timeout:                        pulumi.String("1s"),
					DeregisterCriticalServiceAfter: pulumi.String("30s"),
					Headers: consul.ServiceCheckHeaderArray{
						&consul.ServiceCheckHeaderArgs{
							Name: pulumi.String("foo"),
							Values: pulumi.StringArray{
								pulumi.String("test"),
							},
						},
						&consul.ServiceCheckHeaderArgs{
							Name: pulumi.String("bar"),
							Values: pulumi.StringArray{
								pulumi.String("test"),
							},
						},
					},
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Consul = Pulumi.Consul;

return await Deployment.RunAsync(() => 
{
    var redis = new Consul.Service("redis", new()
    {
        Name = "redis",
        Node = "redis",
        Port = 6379,
        Checks = new[]
        {
            new Consul.Inputs.ServiceCheckArgs
            {
                CheckId = "service:redis1",
                Name = "Redis health check",
                Status = "passing",
                Http = "https://www.hashicorptest.com",
                TlsSkipVerify = false,
                Method = "PUT",
                Interval = "5s",
                Timeout = "1s",
                DeregisterCriticalServiceAfter = "30s",
                Headers = new[]
                {
                    new Consul.Inputs.ServiceCheckHeaderArgs
                    {
                        Name = "foo",
                        Values = new[]
                        {
                            "test",
                        },
                    },
                    new Consul.Inputs.ServiceCheckHeaderArgs
                    {
                        Name = "bar",
                        Values = new[]
                        {
                            "test",
                        },
                    },
                },
            },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.consul.Service;
import com.pulumi.consul.ServiceArgs;
import com.pulumi.consul.inputs.ServiceCheckArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var redis = new Service("redis", ServiceArgs.builder()
            .name("redis")
            .node("redis")
            .port(6379)
            .checks(ServiceCheckArgs.builder()
                .checkId("service:redis1")
                .name("Redis health check")
                .status("passing")
                .http("https://www.hashicorptest.com")
                .tlsSkipVerify(false)
                .method("PUT")
                .interval("5s")
                .timeout("1s")
                .deregisterCriticalServiceAfter("30s")
                .headers(                
                    ServiceCheckHeaderArgs.builder()
                        .name("foo")
                        .values("test")
                        .build(),
                    ServiceCheckHeaderArgs.builder()
                        .name("bar")
                        .values("test")
                        .build())
                .build())
            .build());

    }
}
Copy
resources:
  redis:
    type: consul:Service
    properties:
      name: redis
      node: redis
      port: 6379
      checks:
        - checkId: service:redis1
          name: Redis health check
          status: passing
          http: https://www.hashicorptest.com
          tlsSkipVerify: false
          method: PUT
          interval: 5s
          timeout: 1s
          deregisterCriticalServiceAfter: 30s
          headers:
            - name: foo
              values:
                - test
            - name: bar
              values:
                - test
Copy

Create Service Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Service(name: string, args: ServiceArgs, opts?: CustomResourceOptions);
@overload
def Service(resource_name: str,
            args: ServiceArgs,
            opts: Optional[ResourceOptions] = None)

@overload
def Service(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            node: Optional[str] = None,
            name: Optional[str] = None,
            datacenter: Optional[str] = None,
            enable_tag_override: Optional[bool] = None,
            external: Optional[bool] = None,
            meta: Optional[Mapping[str, str]] = None,
            address: Optional[str] = None,
            namespace: Optional[str] = None,
            checks: Optional[Sequence[ServiceCheckArgs]] = None,
            partition: Optional[str] = None,
            port: Optional[int] = None,
            service_id: Optional[str] = None,
            tags: Optional[Sequence[str]] = None)
func NewService(ctx *Context, name string, args ServiceArgs, opts ...ResourceOption) (*Service, error)
public Service(string name, ServiceArgs args, CustomResourceOptions? opts = null)
public Service(String name, ServiceArgs args)
public Service(String name, ServiceArgs args, CustomResourceOptions options)
type: consul:Service
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ServiceArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. 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 This property is required. string
The unique name of the resource.
args This property is required. ServiceArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ServiceArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ServiceArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var serviceResource = new Consul.Service("serviceResource", new()
{
    Node = "string",
    Name = "string",
    Datacenter = "string",
    EnableTagOverride = false,
    Meta = 
    {
        { "string", "string" },
    },
    Address = "string",
    Namespace = "string",
    Checks = new[]
    {
        new Consul.Inputs.ServiceCheckArgs
        {
            CheckId = "string",
            Interval = "string",
            Name = "string",
            Timeout = "string",
            DeregisterCriticalServiceAfter = "string",
            Headers = new[]
            {
                new Consul.Inputs.ServiceCheckHeaderArgs
                {
                    Name = "string",
                    Values = new[]
                    {
                        "string",
                    },
                },
            },
            Http = "string",
            Method = "string",
            Notes = "string",
            Status = "string",
            Tcp = "string",
            TlsSkipVerify = false,
        },
    },
    Partition = "string",
    Port = 0,
    ServiceId = "string",
    Tags = new[]
    {
        "string",
    },
});
Copy
example, err := consul.NewService(ctx, "serviceResource", &consul.ServiceArgs{
	Node:              pulumi.String("string"),
	Name:              pulumi.String("string"),
	Datacenter:        pulumi.String("string"),
	EnableTagOverride: pulumi.Bool(false),
	Meta: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	Address:   pulumi.String("string"),
	Namespace: pulumi.String("string"),
	Checks: consul.ServiceCheckArray{
		&consul.ServiceCheckArgs{
			CheckId:                        pulumi.String("string"),
			Interval:                       pulumi.String("string"),
			Name:                           pulumi.String("string"),
			Timeout:                        pulumi.String("string"),
			DeregisterCriticalServiceAfter: pulumi.String("string"),
			Headers: consul.ServiceCheckHeaderArray{
				&consul.ServiceCheckHeaderArgs{
					Name: pulumi.String("string"),
					Values: pulumi.StringArray{
						pulumi.String("string"),
					},
				},
			},
			Http:          pulumi.String("string"),
			Method:        pulumi.String("string"),
			Notes:         pulumi.String("string"),
			Status:        pulumi.String("string"),
			Tcp:           pulumi.String("string"),
			TlsSkipVerify: pulumi.Bool(false),
		},
	},
	Partition: pulumi.String("string"),
	Port:      pulumi.Int(0),
	ServiceId: pulumi.String("string"),
	Tags: pulumi.StringArray{
		pulumi.String("string"),
	},
})
Copy
var serviceResource = new Service("serviceResource", ServiceArgs.builder()
    .node("string")
    .name("string")
    .datacenter("string")
    .enableTagOverride(false)
    .meta(Map.of("string", "string"))
    .address("string")
    .namespace("string")
    .checks(ServiceCheckArgs.builder()
        .checkId("string")
        .interval("string")
        .name("string")
        .timeout("string")
        .deregisterCriticalServiceAfter("string")
        .headers(ServiceCheckHeaderArgs.builder()
            .name("string")
            .values("string")
            .build())
        .http("string")
        .method("string")
        .notes("string")
        .status("string")
        .tcp("string")
        .tlsSkipVerify(false)
        .build())
    .partition("string")
    .port(0)
    .serviceId("string")
    .tags("string")
    .build());
Copy
service_resource = consul.Service("serviceResource",
    node="string",
    name="string",
    datacenter="string",
    enable_tag_override=False,
    meta={
        "string": "string",
    },
    address="string",
    namespace="string",
    checks=[{
        "check_id": "string",
        "interval": "string",
        "name": "string",
        "timeout": "string",
        "deregister_critical_service_after": "string",
        "headers": [{
            "name": "string",
            "values": ["string"],
        }],
        "http": "string",
        "method": "string",
        "notes": "string",
        "status": "string",
        "tcp": "string",
        "tls_skip_verify": False,
    }],
    partition="string",
    port=0,
    service_id="string",
    tags=["string"])
Copy
const serviceResource = new consul.Service("serviceResource", {
    node: "string",
    name: "string",
    datacenter: "string",
    enableTagOverride: false,
    meta: {
        string: "string",
    },
    address: "string",
    namespace: "string",
    checks: [{
        checkId: "string",
        interval: "string",
        name: "string",
        timeout: "string",
        deregisterCriticalServiceAfter: "string",
        headers: [{
            name: "string",
            values: ["string"],
        }],
        http: "string",
        method: "string",
        notes: "string",
        status: "string",
        tcp: "string",
        tlsSkipVerify: false,
    }],
    partition: "string",
    port: 0,
    serviceId: "string",
    tags: ["string"],
});
Copy
type: consul:Service
properties:
    address: string
    checks:
        - checkId: string
          deregisterCriticalServiceAfter: string
          headers:
            - name: string
              values:
                - string
          http: string
          interval: string
          method: string
          name: string
          notes: string
          status: string
          tcp: string
          timeout: string
          tlsSkipVerify: false
    datacenter: string
    enableTagOverride: false
    meta:
        string: string
    name: string
    namespace: string
    node: string
    partition: string
    port: 0
    serviceId: string
    tags:
        - string
Copy

Service Resource Properties

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

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Service resource accepts the following input properties:

Node
This property is required.
Changes to this property will trigger replacement.
string
The name of the node the to register the service on.
Address string
The address of the service. Defaults to the address of the node.
Checks List<ServiceCheck>
Datacenter Changes to this property will trigger replacement. string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
EnableTagOverride bool
Specifies to disable the anti-entropy feature for this service's tags. Defaults to false.
External bool

Deprecated: The external field has been deprecated and does nothing.

Meta Dictionary<string, string>
A map of arbitrary KV metadata linked to the service instance.
Name Changes to this property will trigger replacement. string
The name of the service.
Namespace Changes to this property will trigger replacement. string
The namespace to create the service within.
Partition Changes to this property will trigger replacement. string
The partition the service is associated with.
Port int
The port of the service.
ServiceId Changes to this property will trigger replacement. string
If the service ID is not provided, it will be defaulted to the value of the name attribute.
Tags List<string>
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
Node
This property is required.
Changes to this property will trigger replacement.
string
The name of the node the to register the service on.
Address string
The address of the service. Defaults to the address of the node.
Checks []ServiceCheckArgs
Datacenter Changes to this property will trigger replacement. string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
EnableTagOverride bool
Specifies to disable the anti-entropy feature for this service's tags. Defaults to false.
External bool

Deprecated: The external field has been deprecated and does nothing.

Meta map[string]string
A map of arbitrary KV metadata linked to the service instance.
Name Changes to this property will trigger replacement. string
The name of the service.
Namespace Changes to this property will trigger replacement. string
The namespace to create the service within.
Partition Changes to this property will trigger replacement. string
The partition the service is associated with.
Port int
The port of the service.
ServiceId Changes to this property will trigger replacement. string
If the service ID is not provided, it will be defaulted to the value of the name attribute.
Tags []string
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
node
This property is required.
Changes to this property will trigger replacement.
String
The name of the node the to register the service on.
address String
The address of the service. Defaults to the address of the node.
checks List<ServiceCheck>
datacenter Changes to this property will trigger replacement. String
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
enableTagOverride Boolean
Specifies to disable the anti-entropy feature for this service's tags. Defaults to false.
external Boolean

Deprecated: The external field has been deprecated and does nothing.

meta Map<String,String>
A map of arbitrary KV metadata linked to the service instance.
name Changes to this property will trigger replacement. String
The name of the service.
namespace Changes to this property will trigger replacement. String
The namespace to create the service within.
partition Changes to this property will trigger replacement. String
The partition the service is associated with.
port Integer
The port of the service.
serviceId Changes to this property will trigger replacement. String
If the service ID is not provided, it will be defaulted to the value of the name attribute.
tags List<String>
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
node
This property is required.
Changes to this property will trigger replacement.
string
The name of the node the to register the service on.
address string
The address of the service. Defaults to the address of the node.
checks ServiceCheck[]
datacenter Changes to this property will trigger replacement. string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
enableTagOverride boolean
Specifies to disable the anti-entropy feature for this service's tags. Defaults to false.
external boolean

Deprecated: The external field has been deprecated and does nothing.

meta {[key: string]: string}
A map of arbitrary KV metadata linked to the service instance.
name Changes to this property will trigger replacement. string
The name of the service.
namespace Changes to this property will trigger replacement. string
The namespace to create the service within.
partition Changes to this property will trigger replacement. string
The partition the service is associated with.
port number
The port of the service.
serviceId Changes to this property will trigger replacement. string
If the service ID is not provided, it will be defaulted to the value of the name attribute.
tags string[]
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
node
This property is required.
Changes to this property will trigger replacement.
str
The name of the node the to register the service on.
address str
The address of the service. Defaults to the address of the node.
checks Sequence[ServiceCheckArgs]
datacenter Changes to this property will trigger replacement. str
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
enable_tag_override bool
Specifies to disable the anti-entropy feature for this service's tags. Defaults to false.
external bool

Deprecated: The external field has been deprecated and does nothing.

meta Mapping[str, str]
A map of arbitrary KV metadata linked to the service instance.
name Changes to this property will trigger replacement. str
The name of the service.
namespace Changes to this property will trigger replacement. str
The namespace to create the service within.
partition Changes to this property will trigger replacement. str
The partition the service is associated with.
port int
The port of the service.
service_id Changes to this property will trigger replacement. str
If the service ID is not provided, it will be defaulted to the value of the name attribute.
tags Sequence[str]
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
node
This property is required.
Changes to this property will trigger replacement.
String
The name of the node the to register the service on.
address String
The address of the service. Defaults to the address of the node.
checks List<Property Map>
datacenter Changes to this property will trigger replacement. String
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
enableTagOverride Boolean
Specifies to disable the anti-entropy feature for this service's tags. Defaults to false.
external Boolean

Deprecated: The external field has been deprecated and does nothing.

meta Map<String>
A map of arbitrary KV metadata linked to the service instance.
name Changes to this property will trigger replacement. String
The name of the service.
namespace Changes to this property will trigger replacement. String
The namespace to create the service within.
partition Changes to this property will trigger replacement. String
The partition the service is associated with.
port Number
The port of the service.
serviceId Changes to this property will trigger replacement. String
If the service ID is not provided, it will be defaulted to the value of the name attribute.
tags List<String>
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up 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,
        address: Optional[str] = None,
        checks: Optional[Sequence[ServiceCheckArgs]] = None,
        datacenter: Optional[str] = None,
        enable_tag_override: Optional[bool] = None,
        external: Optional[bool] = None,
        meta: Optional[Mapping[str, str]] = None,
        name: Optional[str] = None,
        namespace: Optional[str] = None,
        node: Optional[str] = None,
        partition: Optional[str] = None,
        port: Optional[int] = None,
        service_id: Optional[str] = None,
        tags: Optional[Sequence[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)
public static Service get(String name, Output<String> id, ServiceState state, CustomResourceOptions options)
resources:  _:    type: consul:Service    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
Address string
The address of the service. Defaults to the address of the node.
Checks List<ServiceCheck>
Datacenter Changes to this property will trigger replacement. string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
EnableTagOverride bool
Specifies to disable the anti-entropy feature for this service's tags. Defaults to false.
External bool

Deprecated: The external field has been deprecated and does nothing.

Meta Dictionary<string, string>
A map of arbitrary KV metadata linked to the service instance.
Name Changes to this property will trigger replacement. string
The name of the service.
Namespace Changes to this property will trigger replacement. string
The namespace to create the service within.
Node Changes to this property will trigger replacement. string
The name of the node the to register the service on.
Partition Changes to this property will trigger replacement. string
The partition the service is associated with.
Port int
The port of the service.
ServiceId Changes to this property will trigger replacement. string
If the service ID is not provided, it will be defaulted to the value of the name attribute.
Tags List<string>
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
Address string
The address of the service. Defaults to the address of the node.
Checks []ServiceCheckArgs
Datacenter Changes to this property will trigger replacement. string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
EnableTagOverride bool
Specifies to disable the anti-entropy feature for this service's tags. Defaults to false.
External bool

Deprecated: The external field has been deprecated and does nothing.

Meta map[string]string
A map of arbitrary KV metadata linked to the service instance.
Name Changes to this property will trigger replacement. string
The name of the service.
Namespace Changes to this property will trigger replacement. string
The namespace to create the service within.
Node Changes to this property will trigger replacement. string
The name of the node the to register the service on.
Partition Changes to this property will trigger replacement. string
The partition the service is associated with.
Port int
The port of the service.
ServiceId Changes to this property will trigger replacement. string
If the service ID is not provided, it will be defaulted to the value of the name attribute.
Tags []string
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
address String
The address of the service. Defaults to the address of the node.
checks List<ServiceCheck>
datacenter Changes to this property will trigger replacement. String
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
enableTagOverride Boolean
Specifies to disable the anti-entropy feature for this service's tags. Defaults to false.
external Boolean

Deprecated: The external field has been deprecated and does nothing.

meta Map<String,String>
A map of arbitrary KV metadata linked to the service instance.
name Changes to this property will trigger replacement. String
The name of the service.
namespace Changes to this property will trigger replacement. String
The namespace to create the service within.
node Changes to this property will trigger replacement. String
The name of the node the to register the service on.
partition Changes to this property will trigger replacement. String
The partition the service is associated with.
port Integer
The port of the service.
serviceId Changes to this property will trigger replacement. String
If the service ID is not provided, it will be defaulted to the value of the name attribute.
tags List<String>
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
address string
The address of the service. Defaults to the address of the node.
checks ServiceCheck[]
datacenter Changes to this property will trigger replacement. string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
enableTagOverride boolean
Specifies to disable the anti-entropy feature for this service's tags. Defaults to false.
external boolean

Deprecated: The external field has been deprecated and does nothing.

meta {[key: string]: string}
A map of arbitrary KV metadata linked to the service instance.
name Changes to this property will trigger replacement. string
The name of the service.
namespace Changes to this property will trigger replacement. string
The namespace to create the service within.
node Changes to this property will trigger replacement. string
The name of the node the to register the service on.
partition Changes to this property will trigger replacement. string
The partition the service is associated with.
port number
The port of the service.
serviceId Changes to this property will trigger replacement. string
If the service ID is not provided, it will be defaulted to the value of the name attribute.
tags string[]
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
address str
The address of the service. Defaults to the address of the node.
checks Sequence[ServiceCheckArgs]
datacenter Changes to this property will trigger replacement. str
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
enable_tag_override bool
Specifies to disable the anti-entropy feature for this service's tags. Defaults to false.
external bool

Deprecated: The external field has been deprecated and does nothing.

meta Mapping[str, str]
A map of arbitrary KV metadata linked to the service instance.
name Changes to this property will trigger replacement. str
The name of the service.
namespace Changes to this property will trigger replacement. str
The namespace to create the service within.
node Changes to this property will trigger replacement. str
The name of the node the to register the service on.
partition Changes to this property will trigger replacement. str
The partition the service is associated with.
port int
The port of the service.
service_id Changes to this property will trigger replacement. str
If the service ID is not provided, it will be defaulted to the value of the name attribute.
tags Sequence[str]
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
address String
The address of the service. Defaults to the address of the node.
checks List<Property Map>
datacenter Changes to this property will trigger replacement. String
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
enableTagOverride Boolean
Specifies to disable the anti-entropy feature for this service's tags. Defaults to false.
external Boolean

Deprecated: The external field has been deprecated and does nothing.

meta Map<String>
A map of arbitrary KV metadata linked to the service instance.
name Changes to this property will trigger replacement. String
The name of the service.
namespace Changes to this property will trigger replacement. String
The namespace to create the service within.
node Changes to this property will trigger replacement. String
The name of the node the to register the service on.
partition Changes to this property will trigger replacement. String
The partition the service is associated with.
port Number
The port of the service.
serviceId Changes to this property will trigger replacement. String
If the service ID is not provided, it will be defaulted to the value of the name attribute.
tags List<String>
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.

Supporting Types

ServiceCheck
, ServiceCheckArgs

CheckId This property is required. string
An ID, unique per agent.
Interval This property is required. string
The interval to wait between each health-check invocation.
Name This property is required. string
The name of the health-check.
Timeout This property is required. string
Specifies a timeout for outgoing connections in the case of a HTTP or TCP check.
DeregisterCriticalServiceAfter string
The time after which the service is automatically deregistered when in the critical state. Defaults to 30s. Setting to 0 will disable.
Headers List<ServiceCheckHeader>
The headers to send for an HTTP check. The attributes of each header is given below.
Http string
The HTTP endpoint to call for an HTTP check.
Method string
The method to use for HTTP health-checks. Defaults to GET.
Notes string
An opaque field meant to hold human readable text.
Status string
The initial health-check status.
Tcp string
The TCP address and port to connect to for a TCP check.
TlsSkipVerify bool
Whether to deactivate certificate verification for HTTP health-checks. Defaults to false.
CheckId This property is required. string
An ID, unique per agent.
Interval This property is required. string
The interval to wait between each health-check invocation.
Name This property is required. string
The name of the health-check.
Timeout This property is required. string
Specifies a timeout for outgoing connections in the case of a HTTP or TCP check.
DeregisterCriticalServiceAfter string
The time after which the service is automatically deregistered when in the critical state. Defaults to 30s. Setting to 0 will disable.
Headers []ServiceCheckHeader
The headers to send for an HTTP check. The attributes of each header is given below.
Http string
The HTTP endpoint to call for an HTTP check.
Method string
The method to use for HTTP health-checks. Defaults to GET.
Notes string
An opaque field meant to hold human readable text.
Status string
The initial health-check status.
Tcp string
The TCP address and port to connect to for a TCP check.
TlsSkipVerify bool
Whether to deactivate certificate verification for HTTP health-checks. Defaults to false.
checkId This property is required. String
An ID, unique per agent.
interval This property is required. String
The interval to wait between each health-check invocation.
name This property is required. String
The name of the health-check.
timeout This property is required. String
Specifies a timeout for outgoing connections in the case of a HTTP or TCP check.
deregisterCriticalServiceAfter String
The time after which the service is automatically deregistered when in the critical state. Defaults to 30s. Setting to 0 will disable.
headers List<ServiceCheckHeader>
The headers to send for an HTTP check. The attributes of each header is given below.
http String
The HTTP endpoint to call for an HTTP check.
method String
The method to use for HTTP health-checks. Defaults to GET.
notes String
An opaque field meant to hold human readable text.
status String
The initial health-check status.
tcp String
The TCP address and port to connect to for a TCP check.
tlsSkipVerify Boolean
Whether to deactivate certificate verification for HTTP health-checks. Defaults to false.
checkId This property is required. string
An ID, unique per agent.
interval This property is required. string
The interval to wait between each health-check invocation.
name This property is required. string
The name of the health-check.
timeout This property is required. string
Specifies a timeout for outgoing connections in the case of a HTTP or TCP check.
deregisterCriticalServiceAfter string
The time after which the service is automatically deregistered when in the critical state. Defaults to 30s. Setting to 0 will disable.
headers ServiceCheckHeader[]
The headers to send for an HTTP check. The attributes of each header is given below.
http string
The HTTP endpoint to call for an HTTP check.
method string
The method to use for HTTP health-checks. Defaults to GET.
notes string
An opaque field meant to hold human readable text.
status string
The initial health-check status.
tcp string
The TCP address and port to connect to for a TCP check.
tlsSkipVerify boolean
Whether to deactivate certificate verification for HTTP health-checks. Defaults to false.
check_id This property is required. str
An ID, unique per agent.
interval This property is required. str
The interval to wait between each health-check invocation.
name This property is required. str
The name of the health-check.
timeout This property is required. str
Specifies a timeout for outgoing connections in the case of a HTTP or TCP check.
deregister_critical_service_after str
The time after which the service is automatically deregistered when in the critical state. Defaults to 30s. Setting to 0 will disable.
headers Sequence[ServiceCheckHeader]
The headers to send for an HTTP check. The attributes of each header is given below.
http str
The HTTP endpoint to call for an HTTP check.
method str
The method to use for HTTP health-checks. Defaults to GET.
notes str
An opaque field meant to hold human readable text.
status str
The initial health-check status.
tcp str
The TCP address and port to connect to for a TCP check.
tls_skip_verify bool
Whether to deactivate certificate verification for HTTP health-checks. Defaults to false.
checkId This property is required. String
An ID, unique per agent.
interval This property is required. String
The interval to wait between each health-check invocation.
name This property is required. String
The name of the health-check.
timeout This property is required. String
Specifies a timeout for outgoing connections in the case of a HTTP or TCP check.
deregisterCriticalServiceAfter String
The time after which the service is automatically deregistered when in the critical state. Defaults to 30s. Setting to 0 will disable.
headers List<Property Map>
The headers to send for an HTTP check. The attributes of each header is given below.
http String
The HTTP endpoint to call for an HTTP check.
method String
The method to use for HTTP health-checks. Defaults to GET.
notes String
An opaque field meant to hold human readable text.
status String
The initial health-check status.
tcp String
The TCP address and port to connect to for a TCP check.
tlsSkipVerify Boolean
Whether to deactivate certificate verification for HTTP health-checks. Defaults to false.

ServiceCheckHeader
, ServiceCheckHeaderArgs

Name This property is required. string
The name of the header.
Values This property is required. List<string>
The header's list of values.
Name This property is required. string
The name of the header.
Values This property is required. []string
The header's list of values.
name This property is required. String
The name of the header.
values This property is required. List<String>
The header's list of values.
name This property is required. string
The name of the header.
values This property is required. string[]
The header's list of values.
name This property is required. str
The name of the header.
values This property is required. Sequence[str]
The header's list of values.
name This property is required. String
The name of the header.
values This property is required. List<String>
The header's list of values.

Package Details

Repository
HashiCorp Consul pulumi/pulumi-consul
License
Apache-2.0
Notes
This Pulumi package is based on the consul Terraform Provider.