Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

getService

consul.Service provides details about a specific Consul service in a given datacenter. The results include a list of nodes advertising the specified service, the node’s IP address, port number, node ID, etc. By specifying a different datacenter in the query_options it is possible to retrieve a list of services from a different WAN-attached Consul datacenter.

This data source is different from the consul.getServices (plural) data source, which provides a summary of the current Consul services.

Using getService

function getService(args: GetServiceArgs, opts?: InvokeOptions): Promise<GetServiceResult>
def get_service(datacenter: Optional[str] = None, filter: Optional[str] = None, name: Optional[str] = None, query_options: Optional[Sequence[GetServiceQueryOptionArgs]] = None, tag: Optional[str] = None, opts: Optional[InvokeOptions] = None) -> GetServiceResult
func LookupService(ctx *Context, args *LookupServiceArgs, opts ...InvokeOption) (*LookupServiceResult, error)

Note: This function is named LookupService in the Go SDK.

public static class GetService {
    public static Task<GetServiceResult> InvokeAsync(GetServiceArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Name string

The service name to select.

Datacenter string

The Consul datacenter to query. Defaults to the same value found in query_options parameter specified below, or if that is empty, the datacenter value found in the Consul agent that this provider is configured to talk to.

Filter string

A filter expression to refine the query, see https://www.consul.io/api-docs/features/filtering and https://www.consul.io/api-docs/catalog#filtering-1.

QueryOptions List<GetServiceQueryOptionArgs>

See below.

Tag string

A single tag that can be used to filter the list of nodes to return based on a single matching tag..

Name string

The service name to select.

Datacenter string

The Consul datacenter to query. Defaults to the same value found in query_options parameter specified below, or if that is empty, the datacenter value found in the Consul agent that this provider is configured to talk to.

Filter string

A filter expression to refine the query, see https://www.consul.io/api-docs/features/filtering and https://www.consul.io/api-docs/catalog#filtering-1.

QueryOptions []GetServiceQueryOption

See below.

Tag string

A single tag that can be used to filter the list of nodes to return based on a single matching tag..

name string

The service name to select.

datacenter string

The Consul datacenter to query. Defaults to the same value found in query_options parameter specified below, or if that is empty, the datacenter value found in the Consul agent that this provider is configured to talk to.

filter string

A filter expression to refine the query, see https://www.consul.io/api-docs/features/filtering and https://www.consul.io/api-docs/catalog#filtering-1.

queryOptions GetServiceQueryOption[]

See below.

tag string

A single tag that can be used to filter the list of nodes to return based on a single matching tag..

name str

The service name to select.

datacenter str

The Consul datacenter to query. Defaults to the same value found in query_options parameter specified below, or if that is empty, the datacenter value found in the Consul agent that this provider is configured to talk to.

filter str

A filter expression to refine the query, see https://www.consul.io/api-docs/features/filtering and https://www.consul.io/api-docs/catalog#filtering-1.

query_options Sequence[GetServiceQueryOptionArgs]

See below.

tag str

A single tag that can be used to filter the list of nodes to return based on a single matching tag..

getService Result

The following output properties are available:

Id string

The provider-assigned unique ID for this managed resource.

Name string

The name of the service

Services List<GetServiceService>

A list of nodes and details about each endpoint advertising a service. Each element in the list is a map of attributes that correspond to each individual node. The list of per-node attributes is detailed below.

Datacenter string

The datacenter the keys are being read from to.

Filter string
QueryOptions List<GetServiceQueryOption>
Tag string

The name of the tag used to filter the list of nodes in service.

Id string

The provider-assigned unique ID for this managed resource.

Name string

The name of the service

Services []GetServiceService

A list of nodes and details about each endpoint advertising a service. Each element in the list is a map of attributes that correspond to each individual node. The list of per-node attributes is detailed below.

Datacenter string

The datacenter the keys are being read from to.

Filter string
QueryOptions []GetServiceQueryOption
Tag string

The name of the tag used to filter the list of nodes in service.

id string

The provider-assigned unique ID for this managed resource.

name string

The name of the service

services GetServiceService[]

A list of nodes and details about each endpoint advertising a service. Each element in the list is a map of attributes that correspond to each individual node. The list of per-node attributes is detailed below.

datacenter string

The datacenter the keys are being read from to.

filter string
queryOptions GetServiceQueryOption[]
tag string

The name of the tag used to filter the list of nodes in service.

id str

The provider-assigned unique ID for this managed resource.

name str

The name of the service

services Sequence[GetServiceService]

A list of nodes and details about each endpoint advertising a service. Each element in the list is a map of attributes that correspond to each individual node. The list of per-node attributes is detailed below.

datacenter str

The datacenter the keys are being read from to.

filter str
query_options Sequence[GetServiceQueryOption]
tag str

The name of the tag used to filter the list of nodes in service.

Supporting Types

GetServiceQueryOption

AllowStale bool

When true, the default, allow responses from Consul servers that are followers.

Datacenter string

The Consul datacenter to query. Defaults to the same value found in query_options parameter specified below, or if that is empty, the datacenter value found in the Consul agent that this provider is configured to talk to.

Namespace string

The namespace to lookup the service.

Near string
NodeMeta Dictionary<string, string>
RequireConsistent bool

When true force the client to perform a read on at least quorum servers and verify the result is the same. Defaults to false.

Token string

Specify the Consul ACL token to use when performing the request. This defaults to the same API token configured by the consul provider but may be overriden if necessary.

WaitIndex int

Index number used to enable blocking quereis.

WaitTime string

Max time the client should wait for a blocking query to return.

AllowStale bool

When true, the default, allow responses from Consul servers that are followers.

Datacenter string

The Consul datacenter to query. Defaults to the same value found in query_options parameter specified below, or if that is empty, the datacenter value found in the Consul agent that this provider is configured to talk to.

Namespace string

The namespace to lookup the service.

Near string
NodeMeta map[string]string
RequireConsistent bool

When true force the client to perform a read on at least quorum servers and verify the result is the same. Defaults to false.

Token string

Specify the Consul ACL token to use when performing the request. This defaults to the same API token configured by the consul provider but may be overriden if necessary.

WaitIndex int

Index number used to enable blocking quereis.

WaitTime string

Max time the client should wait for a blocking query to return.

allowStale boolean

When true, the default, allow responses from Consul servers that are followers.

datacenter string

The Consul datacenter to query. Defaults to the same value found in query_options parameter specified below, or if that is empty, the datacenter value found in the Consul agent that this provider is configured to talk to.

namespace string

The namespace to lookup the service.

near string
nodeMeta {[key: string]: string}
requireConsistent boolean

When true force the client to perform a read on at least quorum servers and verify the result is the same. Defaults to false.

token string

Specify the Consul ACL token to use when performing the request. This defaults to the same API token configured by the consul provider but may be overriden if necessary.

waitIndex number

Index number used to enable blocking quereis.

waitTime string

Max time the client should wait for a blocking query to return.

allow_stale bool

When true, the default, allow responses from Consul servers that are followers.

datacenter str

The Consul datacenter to query. Defaults to the same value found in query_options parameter specified below, or if that is empty, the datacenter value found in the Consul agent that this provider is configured to talk to.

namespace str

The namespace to lookup the service.

near str
node_meta Mapping[str, str]
require_consistent bool

When true force the client to perform a read on at least quorum servers and verify the result is the same. Defaults to false.

token str

Specify the Consul ACL token to use when performing the request. This defaults to the same API token configured by the consul provider but may be overriden if necessary.

wait_index int

Index number used to enable blocking quereis.

wait_time str

Max time the client should wait for a blocking query to return.

GetServiceService

Address string
CreateIndex string
EnableTagOverride string
Id string
Meta Dictionary<string, string>
ModifyIndex string
Name string

The service name to select.

NodeAddress string
NodeId string

The Node ID of the Consul agent advertising the service. * node_meta - Node meta data tag information, if any. * node_name - The name of the Consul node. * address - The IP address of the service. If the ServiceAddress in the Consul catalog is empty, this value is automatically populated with the node_address (the Address in the Consul Catalog). * enable_tag_override - Whether service tags can be overridden on this service. * id - A unique service instance identifier. * name - The name of the service. * port - Port number of the service. * tagged_addresses - List of explicit LAN and WAN IP addresses for the agent. * tags - List of tags for the service. * meta - Service meta data tag information, if any.

NodeMeta Dictionary<string, string>
NodeName string
Port string
TaggedAddresses Dictionary<string, string>
Tags List<string>
Address string
CreateIndex string
EnableTagOverride string
Id string
Meta map[string]string
ModifyIndex string
Name string

The service name to select.

NodeAddress string
NodeId string

The Node ID of the Consul agent advertising the service. * node_meta - Node meta data tag information, if any. * node_name - The name of the Consul node. * address - The IP address of the service. If the ServiceAddress in the Consul catalog is empty, this value is automatically populated with the node_address (the Address in the Consul Catalog). * enable_tag_override - Whether service tags can be overridden on this service. * id - A unique service instance identifier. * name - The name of the service. * port - Port number of the service. * tagged_addresses - List of explicit LAN and WAN IP addresses for the agent. * tags - List of tags for the service. * meta - Service meta data tag information, if any.

NodeMeta map[string]string
NodeName string
Port string
TaggedAddresses map[string]string
Tags []string
address string
createIndex string
enableTagOverride string
id string
meta {[key: string]: string}
modifyIndex string
name string

The service name to select.

nodeAddress string
nodeId string

The Node ID of the Consul agent advertising the service. * node_meta - Node meta data tag information, if any. * node_name - The name of the Consul node. * address - The IP address of the service. If the ServiceAddress in the Consul catalog is empty, this value is automatically populated with the node_address (the Address in the Consul Catalog). * enable_tag_override - Whether service tags can be overridden on this service. * id - A unique service instance identifier. * name - The name of the service. * port - Port number of the service. * tagged_addresses - List of explicit LAN and WAN IP addresses for the agent. * tags - List of tags for the service. * meta - Service meta data tag information, if any.

nodeMeta {[key: string]: string}
nodeName string
port string
taggedAddresses {[key: string]: string}
tags string[]
address str
create_index str
enable_tag_override str
id str
meta Mapping[str, str]
modify_index str
name str

The service name to select.

node_address str
node_id str

The Node ID of the Consul agent advertising the service. * node_meta - Node meta data tag information, if any. * node_name - The name of the Consul node. * address - The IP address of the service. If the ServiceAddress in the Consul catalog is empty, this value is automatically populated with the node_address (the Address in the Consul Catalog). * enable_tag_override - Whether service tags can be overridden on this service. * id - A unique service instance identifier. * name - The name of the service. * port - Port number of the service. * tagged_addresses - List of explicit LAN and WAN IP addresses for the agent. * tags - List of tags for the service. * meta - Service meta data tag information, if any.

node_meta Mapping[str, str]
node_name str
port str
tagged_addresses Mapping[str, str]
tags Sequence[str]

Package Details

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