1. Packages
  2. Consul Provider
  3. API Docs
  4. getCatalogServices
Consul v3.12.2 published on Wednesday, Oct 16, 2024 by Pulumi

consul.getCatalogServices

Explore with Pulumi AI

consul logo
Consul v3.12.2 published on Wednesday, Oct 16, 2024 by Pulumi
    Deprecated: getCatalogServices has been deprecated in favor of getServices

    The consul.getServices data source returns a list of Consul services that have been registered with the Consul cluster in a given datacenter. 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.Service (singular) data source, which provides a detailed response about a specific Consul service.

    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-dc1 = consul.getServices({
        queryOptions: [{
            datacenter: "dc1",
        }],
    });
    // Set the description to a whitespace delimited list of the services
    const app = new example.index.Resource("app", {description: std.join({
        separator: " ",
        input: names,
    }).result});
    
    import pulumi
    import pulumi_consul as consul
    import pulumi_example as example
    import pulumi_std as std
    
    read_dc1 = consul.get_services(query_options=[{
        "datacenter": "dc1",
    }])
    # Set the description to a whitespace delimited list of the services
    app = example.index.Resource("app", description=std.join(separator= ,
        input=names).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.GetServices(ctx, &consul.GetServicesArgs{
    			QueryOptions: []consul.GetServicesQueryOption{
    				{
    					Datacenter: pulumi.StringRef("dc1"),
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		// Set the description to a whitespace delimited list of the services
    		_, err = example.NewResource(ctx, "app", &example.ResourceArgs{
    			Description: std.Join(ctx, &std.JoinArgs{
    				Separator: " ",
    				Input:     names,
    			}, 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_dc1 = Consul.GetServices.Invoke(new()
        {
            QueryOptions = new[]
            {
                new Consul.Inputs.GetServicesQueryOptionInputArgs
                {
                    Datacenter = "dc1",
                },
            },
        });
    
        // Set the description to a whitespace delimited list of the services
        var app = new Example.Index.Resource("app", new()
        {
            Description = Std.Join.Invoke(new()
            {
                Separator = " ",
                Input = names,
            }).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.GetServicesArgs;
    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-dc1 = ConsulFunctions.getServices(GetServicesArgs.builder()
                .queryOptions(GetServicesQueryOptionArgs.builder()
                    .datacenter("dc1")
                    .build())
                .build());
    
            // Set the description to a whitespace delimited list of the services
            var app = new Resource("app", ResourceArgs.builder()
                .description(StdFunctions.join(JoinArgs.builder()
                    .separator(" ")
                    .input(names)
                    .build()).result())
                .build());
    
        }
    }
    
    resources:
      # Set the description to a whitespace delimited list of the services
      app:
        type: example:resource
        properties:
          description:
            fn::invoke:
              Function: std:join
              Arguments:
                separator: ' '
                input: ${names}
              Return: result
    variables:
      read-dc1:
        fn::invoke:
          Function: consul:getServices
          Arguments:
            queryOptions:
              - datacenter: dc1
    

    Using getCatalogServices

    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 getCatalogServices(args: GetCatalogServicesArgs, opts?: InvokeOptions): Promise<GetCatalogServicesResult>
    function getCatalogServicesOutput(args: GetCatalogServicesOutputArgs, opts?: InvokeOptions): Output<GetCatalogServicesResult>
    def get_catalog_services(query_options: Optional[Sequence[GetCatalogServicesQueryOption]] = None,
                             opts: Optional[InvokeOptions] = None) -> GetCatalogServicesResult
    def get_catalog_services_output(query_options: Optional[pulumi.Input[Sequence[pulumi.Input[GetCatalogServicesQueryOptionArgs]]]] = None,
                             opts: Optional[InvokeOptions] = None) -> Output[GetCatalogServicesResult]
    func GetCatalogServices(ctx *Context, args *GetCatalogServicesArgs, opts ...InvokeOption) (*GetCatalogServicesResult, error)
    func GetCatalogServicesOutput(ctx *Context, args *GetCatalogServicesOutputArgs, opts ...InvokeOption) GetCatalogServicesResultOutput

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

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

    The following arguments are supported:

    getCatalogServices Result

    The following output properties are available:

    Datacenter string
    The datacenter the keys are being read from to.
    Id string
    The provider-assigned unique ID for this managed resource.
    Names List<string>
    Services Dictionary<string, string>
    Tags Dictionary<string, string>
    A map of the tags found for each service. If more than one service shares the same tag, unique service names will be joined by whitespace (this is the inverse of services and can be used to lookup the services that match a single tag).
    QueryOptions List<GetCatalogServicesQueryOption>
    Datacenter string
    The datacenter the keys are being read from to.
    Id string
    The provider-assigned unique ID for this managed resource.
    Names []string
    Services map[string]string
    Tags map[string]string
    A map of the tags found for each service. If more than one service shares the same tag, unique service names will be joined by whitespace (this is the inverse of services and can be used to lookup the services that match a single tag).
    QueryOptions []GetCatalogServicesQueryOption
    datacenter String
    The datacenter the keys are being read from to.
    id String
    The provider-assigned unique ID for this managed resource.
    names List<String>
    services Map<String,String>
    tags Map<String,String>
    A map of the tags found for each service. If more than one service shares the same tag, unique service names will be joined by whitespace (this is the inverse of services and can be used to lookup the services that match a single tag).
    queryOptions List<GetCatalogServicesQueryOption>
    datacenter string
    The datacenter the keys are being read from to.
    id string
    The provider-assigned unique ID for this managed resource.
    names string[]
    services {[key: string]: string}
    tags {[key: string]: string}
    A map of the tags found for each service. If more than one service shares the same tag, unique service names will be joined by whitespace (this is the inverse of services and can be used to lookup the services that match a single tag).
    queryOptions GetCatalogServicesQueryOption[]
    datacenter str
    The datacenter the keys are being read from to.
    id str
    The provider-assigned unique ID for this managed resource.
    names Sequence[str]
    services Mapping[str, str]
    tags Mapping[str, str]
    A map of the tags found for each service. If more than one service shares the same tag, unique service names will be joined by whitespace (this is the inverse of services and can be used to lookup the services that match a single tag).
    query_options Sequence[GetCatalogServicesQueryOption]
    datacenter String
    The datacenter the keys are being read from to.
    id String
    The provider-assigned unique ID for this managed resource.
    names List<String>
    services Map<String>
    tags Map<String>
    A map of the tags found for each service. If more than one service shares the same tag, unique service names will be joined by whitespace (this is the inverse of services and can be used to lookup the services that match a single tag).
    queryOptions List<Property Map>

    Supporting Types

    GetCatalogServicesQueryOption

    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 services.
    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 services.
    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 services.
    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 services.
    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 services.
    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 services.
    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.

    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.2 published on Wednesday, Oct 16, 2024 by Pulumi