1. Packages
  2. Consul Provider
  3. API Docs
  4. getCatalogService
Consul v3.12.1 published on Friday, Aug 23, 2024 by Pulumi

consul.getCatalogService

Explore with Pulumi AI

consul logo
Consul v3.12.1 published on Friday, Aug 23, 2024 by Pulumi
    Deprecated: getCatalogService has been deprecated in favor of 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.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as consul from "@pulumi/consul";
    import * as example from "@pulumi/example";
    import * as std from "@pulumi/std";
    
    const read-consul-dc1 = consul.getService({
        name: "consul",
        datacenter: "dc1",
    });
    // Set the description to a whitespace delimited list of the node names
    const app = new example.index.Resource("app", {description: std.join({
        separator: " ",
        input: nodes,
    }).result});
    
    import pulumi
    import pulumi_consul as consul
    import pulumi_example as example
    import pulumi_std as std
    
    read_consul_dc1 = consul.get_service(name="consul",
        datacenter="dc1")
    # Set the description to a whitespace delimited list of the node names
    app = example.index.Resource("app", description=std.join(separator= ,
        input=nodes).result)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-consul/sdk/v3/go/consul"
    	"github.com/pulumi/pulumi-example/sdk/go/example"
    	"github.com/pulumi/pulumi-std/sdk/go/std"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := consul.LookupService(ctx, &consul.LookupServiceArgs{
    			Name:       "consul",
    			Datacenter: pulumi.StringRef("dc1"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		// Set the description to a whitespace delimited list of the node names
    		_, err = example.NewResource(ctx, "app", &example.ResourceArgs{
    			Description: std.Join(ctx, &std.JoinArgs{
    				Separator: " ",
    				Input:     nodes,
    			}, nil).Result,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Consul = Pulumi.Consul;
    using Example = Pulumi.Example;
    using Std = Pulumi.Std;
    
    return await Deployment.RunAsync(() => 
    {
        var read_consul_dc1 = Consul.GetService.Invoke(new()
        {
            Name = "consul",
            Datacenter = "dc1",
        });
    
        // Set the description to a whitespace delimited list of the node names
        var app = new Example.Index.Resource("app", new()
        {
            Description = Std.Join.Invoke(new()
            {
                Separator = " ",
                Input = nodes,
            }).Result,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.consul.ConsulFunctions;
    import com.pulumi.consul.inputs.GetServiceArgs;
    import com.pulumi.example.resource;
    import com.pulumi.example.ResourceArgs;
    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) {
            final var read-consul-dc1 = ConsulFunctions.getService(GetServiceArgs.builder()
                .name("consul")
                .datacenter("dc1")
                .build());
    
            // Set the description to a whitespace delimited list of the node names
            var app = new Resource("app", ResourceArgs.builder()
                .description(StdFunctions.join(JoinArgs.builder()
                    .separator(" ")
                    .input(nodes)
                    .build()).result())
                .build());
    
        }
    }
    
    resources:
      # Set the description to a whitespace delimited list of the node names
      app:
        type: example:resource
        properties:
          description:
            fn::invoke:
              Function: std:join
              Arguments:
                separator: ' '
                input: ${nodes}
              Return: result
    variables:
      read-consul-dc1:
        fn::invoke:
          Function: consul:getService
          Arguments:
            name: consul
            datacenter: dc1
    

    Using getCatalogService

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getCatalogService(args: GetCatalogServiceArgs, opts?: InvokeOptions): Promise<GetCatalogServiceResult>
    function getCatalogServiceOutput(args: GetCatalogServiceOutputArgs, opts?: InvokeOptions): Output<GetCatalogServiceResult>
    def get_catalog_service(datacenter: Optional[str] = None,
                            filter: Optional[str] = None,
                            name: Optional[str] = None,
                            query_options: Optional[Sequence[GetCatalogServiceQueryOption]] = None,
                            tag: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetCatalogServiceResult
    def get_catalog_service_output(datacenter: Optional[pulumi.Input[str]] = None,
                            filter: Optional[pulumi.Input[str]] = None,
                            name: Optional[pulumi.Input[str]] = None,
                            query_options: Optional[pulumi.Input[Sequence[pulumi.Input[GetCatalogServiceQueryOptionArgs]]]] = None,
                            tag: Optional[pulumi.Input[str]] = None,
                            opts: Optional[InvokeOptions] = None) -> Output[GetCatalogServiceResult]
    func GetCatalogService(ctx *Context, args *GetCatalogServiceArgs, opts ...InvokeOption) (*GetCatalogServiceResult, error)
    func GetCatalogServiceOutput(ctx *Context, args *GetCatalogServiceOutputArgs, opts ...InvokeOption) GetCatalogServiceResultOutput

    > Note: This function is named GetCatalogService in the Go SDK.

    public static class GetCatalogService 
    {
        public static Task<GetCatalogServiceResult> InvokeAsync(GetCatalogServiceArgs args, InvokeOptions? opts = null)
        public static Output<GetCatalogServiceResult> Invoke(GetCatalogServiceInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetCatalogServiceResult> getCatalogService(GetCatalogServiceArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: consul:index/getCatalogService:getCatalogService
      arguments:
        # arguments dictionary

    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
    QueryOptions List<GetCatalogServiceQueryOption>
    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
    QueryOptions []GetCatalogServiceQueryOption
    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
    queryOptions List<GetCatalogServiceQueryOption>
    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
    queryOptions GetCatalogServiceQueryOption[]
    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
    query_options Sequence[GetCatalogServiceQueryOption]
    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..
    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
    queryOptions List<Property Map>
    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..

    getCatalogService 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<GetCatalogServiceService>
    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<GetCatalogServiceQueryOption>
    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 []GetCatalogServiceService
    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 []GetCatalogServiceQueryOption
    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 List<GetCatalogServiceService>
    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<GetCatalogServiceQueryOption>
    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 GetCatalogServiceService[]
    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 GetCatalogServiceQueryOption[]
    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[GetCatalogServiceService]
    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[GetCatalogServiceQueryOption]
    tag str
    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 List<Property Map>
    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<Property Map>
    tag String
    The name of the tag used to filter the list of nodes in service.

    Supporting Types

    GetCatalogServiceQueryOption

    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>
    Partition 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 overridden if necessary.
    WaitIndex int
    Index number used to enable blocking queries.
    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
    Partition 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 overridden if necessary.
    WaitIndex int
    Index number used to enable blocking queries.
    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 Map<String,String>
    partition 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 overridden if necessary.
    waitIndex Integer
    Index number used to enable blocking queries.
    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}
    partition 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 overridden if necessary.
    waitIndex number
    Index number used to enable blocking queries.
    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]
    partition 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 overridden if necessary.
    wait_index int
    Index number used to enable blocking queries.
    wait_time str
    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 Map<String>
    partition 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 overridden if necessary.
    waitIndex Number
    Index number used to enable blocking queries.
    waitTime String
    Max time the client should wait for a blocking query to return.

    GetCatalogServiceService

    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 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 List<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]
    address String
    createIndex String
    enableTagOverride String
    id String
    meta Map<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>
    nodeName String
    port String
    taggedAddresses Map<String>
    tags List<String>

    Package Details

    Repository
    HashiCorp Consul pulumi/pulumi-consul
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the consul Terraform Provider.
    consul logo
    Consul v3.12.1 published on Friday, Aug 23, 2024 by Pulumi