1. Packages
  2. HashiCorp Consul
  3. API Docs
  4. PreparedQuery
Consul v3.11.1 published on Friday, Jan 19, 2024 by Pulumi

consul.PreparedQuery

Explore with Pulumi AI

consul logo
Consul v3.11.1 published on Friday, Jan 19, 2024 by Pulumi

    Import

     $ pulumi import consul:index/preparedQuery:PreparedQuery my_service 71ecfb82-717a-4258-b4b6-2fb75144d856
    

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Consul = Pulumi.Consul;
    
    return await Deployment.RunAsync(() => 
    {
        // Creates a prepared query myquery.query.consul that finds the nearest
        // healthy myapp.service.consul instance that has the active tag and not
        // the standby tag.
        var myapp_query = new Consul.PreparedQuery("myapp-query", new()
        {
            Datacenter = "us-central1",
            Dns = new Consul.Inputs.PreparedQueryDnsArgs
            {
                Ttl = "30s",
            },
            Failover = new Consul.Inputs.PreparedQueryFailoverArgs
            {
                Datacenters = new[]
                {
                    "us-west1",
                    "us-east-2",
                    "asia-east1",
                },
                NearestN = 3,
            },
            Near = "_agent",
            OnlyPassing = true,
            Service = "myapp",
            StoredToken = "wxyz",
            Tags = new[]
            {
                "active",
                "!standby",
            },
            Token = "abcd",
        });
    
        // Creates a Prepared Query Template that matches *-near-self.query.consul
        // and finds the nearest service that matches the glob character (e.g.
        // foo-near-self.query.consul will find the nearest healthy foo.service.consul).
        var service_near_self = new Consul.PreparedQuery("service-near-self", new()
        {
            Connect = true,
            Datacenter = "nyc1",
            Dns = new Consul.Inputs.PreparedQueryDnsArgs
            {
                Ttl = "5m",
            },
            Failover = new Consul.Inputs.PreparedQueryFailoverArgs
            {
                Datacenters = new[]
                {
                    "dc2",
                    "dc3",
                    "dc4",
                },
                NearestN = 3,
            },
            Near = "_agent",
            OnlyPassing = true,
            Service = "${match(1)}",
            StoredToken = "wxyz",
            Template = new Consul.Inputs.PreparedQueryTemplateArgs
            {
                Regexp = "^(.*)-near-self$",
                Type = "name_prefix_match",
            },
            Token = "abcd",
        });
    
    });
    
    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.NewPreparedQuery(ctx, "myapp-query", &consul.PreparedQueryArgs{
    			Datacenter: pulumi.String("us-central1"),
    			Dns: &consul.PreparedQueryDnsArgs{
    				Ttl: pulumi.String("30s"),
    			},
    			Failover: &consul.PreparedQueryFailoverArgs{
    				Datacenters: pulumi.StringArray{
    					pulumi.String("us-west1"),
    					pulumi.String("us-east-2"),
    					pulumi.String("asia-east1"),
    				},
    				NearestN: pulumi.Int(3),
    			},
    			Near:        pulumi.String("_agent"),
    			OnlyPassing: pulumi.Bool(true),
    			Service:     pulumi.String("myapp"),
    			StoredToken: pulumi.String("wxyz"),
    			Tags: pulumi.StringArray{
    				pulumi.String("active"),
    				pulumi.String("!standby"),
    			},
    			Token: pulumi.String("abcd"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = consul.NewPreparedQuery(ctx, "service-near-self", &consul.PreparedQueryArgs{
    			Connect:    pulumi.Bool(true),
    			Datacenter: pulumi.String("nyc1"),
    			Dns: &consul.PreparedQueryDnsArgs{
    				Ttl: pulumi.String("5m"),
    			},
    			Failover: &consul.PreparedQueryFailoverArgs{
    				Datacenters: pulumi.StringArray{
    					pulumi.String("dc2"),
    					pulumi.String("dc3"),
    					pulumi.String("dc4"),
    				},
    				NearestN: pulumi.Int(3),
    			},
    			Near:        pulumi.String("_agent"),
    			OnlyPassing: pulumi.Bool(true),
    			Service:     pulumi.String("${match(1)}"),
    			StoredToken: pulumi.String("wxyz"),
    			Template: &consul.PreparedQueryTemplateArgs{
    				Regexp: pulumi.String("^(.*)-near-self$"),
    				Type:   pulumi.String("name_prefix_match"),
    			},
    			Token: pulumi.String("abcd"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.consul.PreparedQuery;
    import com.pulumi.consul.PreparedQueryArgs;
    import com.pulumi.consul.inputs.PreparedQueryDnsArgs;
    import com.pulumi.consul.inputs.PreparedQueryFailoverArgs;
    import com.pulumi.consul.inputs.PreparedQueryTemplateArgs;
    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 myapp_query = new PreparedQuery("myapp-query", PreparedQueryArgs.builder()        
                .datacenter("us-central1")
                .dns(PreparedQueryDnsArgs.builder()
                    .ttl("30s")
                    .build())
                .failover(PreparedQueryFailoverArgs.builder()
                    .datacenters(                
                        "us-west1",
                        "us-east-2",
                        "asia-east1")
                    .nearestN(3)
                    .build())
                .near("_agent")
                .onlyPassing(true)
                .service("myapp")
                .storedToken("wxyz")
                .tags(            
                    "active",
                    "!standby")
                .token("abcd")
                .build());
    
            var service_near_self = new PreparedQuery("service-near-self", PreparedQueryArgs.builder()        
                .connect(true)
                .datacenter("nyc1")
                .dns(PreparedQueryDnsArgs.builder()
                    .ttl("5m")
                    .build())
                .failover(PreparedQueryFailoverArgs.builder()
                    .datacenters(                
                        "dc2",
                        "dc3",
                        "dc4")
                    .nearestN(3)
                    .build())
                .near("_agent")
                .onlyPassing(true)
                .service("${match(1)}")
                .storedToken("wxyz")
                .template(PreparedQueryTemplateArgs.builder()
                    .regexp("^(.*)-near-self$")
                    .type("name_prefix_match")
                    .build())
                .token("abcd")
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_consul as consul
    
    # Creates a prepared query myquery.query.consul that finds the nearest
    # healthy myapp.service.consul instance that has the active tag and not
    # the standby tag.
    myapp_query = consul.PreparedQuery("myapp-query",
        datacenter="us-central1",
        dns=consul.PreparedQueryDnsArgs(
            ttl="30s",
        ),
        failover=consul.PreparedQueryFailoverArgs(
            datacenters=[
                "us-west1",
                "us-east-2",
                "asia-east1",
            ],
            nearest_n=3,
        ),
        near="_agent",
        only_passing=True,
        service="myapp",
        stored_token="wxyz",
        tags=[
            "active",
            "!standby",
        ],
        token="abcd")
    # Creates a Prepared Query Template that matches *-near-self.query.consul
    # and finds the nearest service that matches the glob character (e.g.
    # foo-near-self.query.consul will find the nearest healthy foo.service.consul).
    service_near_self = consul.PreparedQuery("service-near-self",
        connect=True,
        datacenter="nyc1",
        dns=consul.PreparedQueryDnsArgs(
            ttl="5m",
        ),
        failover=consul.PreparedQueryFailoverArgs(
            datacenters=[
                "dc2",
                "dc3",
                "dc4",
            ],
            nearest_n=3,
        ),
        near="_agent",
        only_passing=True,
        service="${match(1)}",
        stored_token="wxyz",
        template=consul.PreparedQueryTemplateArgs(
            regexp="^(.*)-near-self$",
            type="name_prefix_match",
        ),
        token="abcd")
    
    import * as pulumi from "@pulumi/pulumi";
    import * as consul from "@pulumi/consul";
    
    // Creates a prepared query myquery.query.consul that finds the nearest
    // healthy myapp.service.consul instance that has the active tag and not
    // the standby tag.
    const myapp_query = new consul.PreparedQuery("myapp-query", {
        datacenter: "us-central1",
        dns: {
            ttl: "30s",
        },
        failover: {
            datacenters: [
                "us-west1",
                "us-east-2",
                "asia-east1",
            ],
            nearestN: 3,
        },
        near: "_agent",
        onlyPassing: true,
        service: "myapp",
        storedToken: "wxyz",
        tags: [
            "active",
            "!standby",
        ],
        token: "abcd",
    });
    // Creates a Prepared Query Template that matches *-near-self.query.consul
    // and finds the nearest service that matches the glob character (e.g.
    // foo-near-self.query.consul will find the nearest healthy foo.service.consul).
    const service_near_self = new consul.PreparedQuery("service-near-self", {
        connect: true,
        datacenter: "nyc1",
        dns: {
            ttl: "5m",
        },
        failover: {
            datacenters: [
                "dc2",
                "dc3",
                "dc4",
            ],
            nearestN: 3,
        },
        near: "_agent",
        onlyPassing: true,
        service: "${match(1)}",
        storedToken: "wxyz",
        template: {
            regexp: "^(.*)-near-self$",
            type: "name_prefix_match",
        },
        token: "abcd",
    });
    
    resources:
      # Creates a prepared query myquery.query.consul that finds the nearest
      # // healthy myapp.service.consul instance that has the active tag and not
      # // the standby tag.
      myapp-query:
        type: consul:PreparedQuery
        properties:
          datacenter: us-central1
          dns:
            ttl: 30s
          failover:
            datacenters:
              - us-west1
              - us-east-2
              - asia-east1
            nearestN: 3
          near: _agent
          onlyPassing: true
          service: myapp
          storedToken: wxyz
          tags:
            - active
            - '!standby'
          token: abcd
      # Creates a Prepared Query Template that matches *-near-self.query.consul
      # // and finds the nearest service that matches the glob character (e.g.
      # // foo-near-self.query.consul will find the nearest healthy foo.service.consul).
      service-near-self:
        type: consul:PreparedQuery
        properties:
          connect: true
          datacenter: nyc1
          dns:
            ttl: 5m
          failover:
            datacenters:
              - dc2
              - dc3
              - dc4
            nearestN: 3
          near: _agent
          onlyPassing: true
          service: ${match(1)}
          storedToken: wxyz
          template:
            regexp: ^(.*)-near-self$
            type: name_prefix_match
          token: abcd
    

    Create PreparedQuery Resource

    new PreparedQuery(name: string, args: PreparedQueryArgs, opts?: CustomResourceOptions);
    @overload
    def PreparedQuery(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      connect: Optional[bool] = None,
                      datacenter: Optional[str] = None,
                      dns: Optional[PreparedQueryDnsArgs] = None,
                      failover: Optional[PreparedQueryFailoverArgs] = None,
                      ignore_check_ids: Optional[Sequence[str]] = None,
                      name: Optional[str] = None,
                      near: Optional[str] = None,
                      node_meta: Optional[Mapping[str, str]] = None,
                      only_passing: Optional[bool] = None,
                      service: Optional[str] = None,
                      service_meta: Optional[Mapping[str, str]] = None,
                      session: Optional[str] = None,
                      stored_token: Optional[str] = None,
                      tags: Optional[Sequence[str]] = None,
                      template: Optional[PreparedQueryTemplateArgs] = None,
                      token: Optional[str] = None)
    @overload
    def PreparedQuery(resource_name: str,
                      args: PreparedQueryArgs,
                      opts: Optional[ResourceOptions] = None)
    func NewPreparedQuery(ctx *Context, name string, args PreparedQueryArgs, opts ...ResourceOption) (*PreparedQuery, error)
    public PreparedQuery(string name, PreparedQueryArgs args, CustomResourceOptions? opts = null)
    public PreparedQuery(String name, PreparedQueryArgs args)
    public PreparedQuery(String name, PreparedQueryArgs args, CustomResourceOptions options)
    
    type: consul:PreparedQuery
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args PreparedQueryArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args PreparedQueryArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args PreparedQueryArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args PreparedQueryArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args PreparedQueryArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    PreparedQuery Resource Properties

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

    Inputs

    The PreparedQuery resource accepts the following input properties:

    Service string
    The name of the service to query
    Connect bool
    When true the prepared query will return connect proxy services for a queried service. Conditions such as tags in the prepared query will be matched against the proxy service. Defaults to false.
    Datacenter string
    Specifies a WAN federated datacenter to forward the query to.
    Dns PreparedQueryDns
    Settings for controlling the DNS response details.
    Failover PreparedQueryFailover
    Options for controlling behavior when no healthy nodes are available in the local DC.
    IgnoreCheckIds List<string>
    Specifies a list of check IDs that should be ignored when filtering unhealthy instances. This is mostly useful in an emergency or as a temporary measure when a health check is found to be unreliable. Being able to ignore it in centrally-defined queries can be simpler than de-registering the check as an interim solution until the check can be fixed.
    Name string
    The name of the prepared query. Used to identify the prepared query during requests. Can be specified as an empty string to configure the query as a catch-all.
    Near string
    Allows specifying the name of a node to sort results near using Consul's distance sorting and network coordinates. The magic _agent value can be used to always sort nearest the node servicing the request.
    NodeMeta Dictionary<string, string>
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.
    OnlyPassing bool
    When true, the prepared query will only return nodes with passing health checks in the result.
    ServiceMeta Dictionary<string, string>
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to services with the given metadata values present.
    Session string
    The name of the Consul session to tie this query's lifetime to. This is an advanced parameter that should not be used without a complete understanding of Consul sessions and the implications of their use (it is recommended to leave this blank in nearly all cases). If this parameter is omitted the query will not expire.
    StoredToken string
    The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
    Tags List<string>
    The list of required and/or disallowed tags. If a tag is in this list it must be present. If the tag is preceded with a "!" then it is disallowed.
    Template PreparedQueryTemplate
    Query templating options. This is used to make a single prepared query respond to many different requests
    Token string
    The ACL token to use when saving the prepared query. This overrides the token that the agent provides by default.

    Deprecated:The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

    Service string
    The name of the service to query
    Connect bool
    When true the prepared query will return connect proxy services for a queried service. Conditions such as tags in the prepared query will be matched against the proxy service. Defaults to false.
    Datacenter string
    Specifies a WAN federated datacenter to forward the query to.
    Dns PreparedQueryDnsArgs
    Settings for controlling the DNS response details.
    Failover PreparedQueryFailoverArgs
    Options for controlling behavior when no healthy nodes are available in the local DC.
    IgnoreCheckIds []string
    Specifies a list of check IDs that should be ignored when filtering unhealthy instances. This is mostly useful in an emergency or as a temporary measure when a health check is found to be unreliable. Being able to ignore it in centrally-defined queries can be simpler than de-registering the check as an interim solution until the check can be fixed.
    Name string
    The name of the prepared query. Used to identify the prepared query during requests. Can be specified as an empty string to configure the query as a catch-all.
    Near string
    Allows specifying the name of a node to sort results near using Consul's distance sorting and network coordinates. The magic _agent value can be used to always sort nearest the node servicing the request.
    NodeMeta map[string]string
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.
    OnlyPassing bool
    When true, the prepared query will only return nodes with passing health checks in the result.
    ServiceMeta map[string]string
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to services with the given metadata values present.
    Session string
    The name of the Consul session to tie this query's lifetime to. This is an advanced parameter that should not be used without a complete understanding of Consul sessions and the implications of their use (it is recommended to leave this blank in nearly all cases). If this parameter is omitted the query will not expire.
    StoredToken string
    The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
    Tags []string
    The list of required and/or disallowed tags. If a tag is in this list it must be present. If the tag is preceded with a "!" then it is disallowed.
    Template PreparedQueryTemplateArgs
    Query templating options. This is used to make a single prepared query respond to many different requests
    Token string
    The ACL token to use when saving the prepared query. This overrides the token that the agent provides by default.

    Deprecated:The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

    service String
    The name of the service to query
    connect Boolean
    When true the prepared query will return connect proxy services for a queried service. Conditions such as tags in the prepared query will be matched against the proxy service. Defaults to false.
    datacenter String
    Specifies a WAN federated datacenter to forward the query to.
    dns PreparedQueryDns
    Settings for controlling the DNS response details.
    failover PreparedQueryFailover
    Options for controlling behavior when no healthy nodes are available in the local DC.
    ignoreCheckIds List<String>
    Specifies a list of check IDs that should be ignored when filtering unhealthy instances. This is mostly useful in an emergency or as a temporary measure when a health check is found to be unreliable. Being able to ignore it in centrally-defined queries can be simpler than de-registering the check as an interim solution until the check can be fixed.
    name String
    The name of the prepared query. Used to identify the prepared query during requests. Can be specified as an empty string to configure the query as a catch-all.
    near String
    Allows specifying the name of a node to sort results near using Consul's distance sorting and network coordinates. The magic _agent value can be used to always sort nearest the node servicing the request.
    nodeMeta Map<String,String>
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.
    onlyPassing Boolean
    When true, the prepared query will only return nodes with passing health checks in the result.
    serviceMeta Map<String,String>
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to services with the given metadata values present.
    session String
    The name of the Consul session to tie this query's lifetime to. This is an advanced parameter that should not be used without a complete understanding of Consul sessions and the implications of their use (it is recommended to leave this blank in nearly all cases). If this parameter is omitted the query will not expire.
    storedToken String
    The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
    tags List<String>
    The list of required and/or disallowed tags. If a tag is in this list it must be present. If the tag is preceded with a "!" then it is disallowed.
    template PreparedQueryTemplate
    Query templating options. This is used to make a single prepared query respond to many different requests
    token String
    The ACL token to use when saving the prepared query. This overrides the token that the agent provides by default.

    Deprecated:The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

    service string
    The name of the service to query
    connect boolean
    When true the prepared query will return connect proxy services for a queried service. Conditions such as tags in the prepared query will be matched against the proxy service. Defaults to false.
    datacenter string
    Specifies a WAN federated datacenter to forward the query to.
    dns PreparedQueryDns
    Settings for controlling the DNS response details.
    failover PreparedQueryFailover
    Options for controlling behavior when no healthy nodes are available in the local DC.
    ignoreCheckIds string[]
    Specifies a list of check IDs that should be ignored when filtering unhealthy instances. This is mostly useful in an emergency or as a temporary measure when a health check is found to be unreliable. Being able to ignore it in centrally-defined queries can be simpler than de-registering the check as an interim solution until the check can be fixed.
    name string
    The name of the prepared query. Used to identify the prepared query during requests. Can be specified as an empty string to configure the query as a catch-all.
    near string
    Allows specifying the name of a node to sort results near using Consul's distance sorting and network coordinates. The magic _agent value can be used to always sort nearest the node servicing the request.
    nodeMeta {[key: string]: string}
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.
    onlyPassing boolean
    When true, the prepared query will only return nodes with passing health checks in the result.
    serviceMeta {[key: string]: string}
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to services with the given metadata values present.
    session string
    The name of the Consul session to tie this query's lifetime to. This is an advanced parameter that should not be used without a complete understanding of Consul sessions and the implications of their use (it is recommended to leave this blank in nearly all cases). If this parameter is omitted the query will not expire.
    storedToken string
    The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
    tags string[]
    The list of required and/or disallowed tags. If a tag is in this list it must be present. If the tag is preceded with a "!" then it is disallowed.
    template PreparedQueryTemplate
    Query templating options. This is used to make a single prepared query respond to many different requests
    token string
    The ACL token to use when saving the prepared query. This overrides the token that the agent provides by default.

    Deprecated:The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

    service str
    The name of the service to query
    connect bool
    When true the prepared query will return connect proxy services for a queried service. Conditions such as tags in the prepared query will be matched against the proxy service. Defaults to false.
    datacenter str
    Specifies a WAN federated datacenter to forward the query to.
    dns PreparedQueryDnsArgs
    Settings for controlling the DNS response details.
    failover PreparedQueryFailoverArgs
    Options for controlling behavior when no healthy nodes are available in the local DC.
    ignore_check_ids Sequence[str]
    Specifies a list of check IDs that should be ignored when filtering unhealthy instances. This is mostly useful in an emergency or as a temporary measure when a health check is found to be unreliable. Being able to ignore it in centrally-defined queries can be simpler than de-registering the check as an interim solution until the check can be fixed.
    name str
    The name of the prepared query. Used to identify the prepared query during requests. Can be specified as an empty string to configure the query as a catch-all.
    near str
    Allows specifying the name of a node to sort results near using Consul's distance sorting and network coordinates. The magic _agent value can be used to always sort nearest the node servicing the request.
    node_meta Mapping[str, str]
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.
    only_passing bool
    When true, the prepared query will only return nodes with passing health checks in the result.
    service_meta Mapping[str, str]
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to services with the given metadata values present.
    session str
    The name of the Consul session to tie this query's lifetime to. This is an advanced parameter that should not be used without a complete understanding of Consul sessions and the implications of their use (it is recommended to leave this blank in nearly all cases). If this parameter is omitted the query will not expire.
    stored_token str
    The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
    tags Sequence[str]
    The list of required and/or disallowed tags. If a tag is in this list it must be present. If the tag is preceded with a "!" then it is disallowed.
    template PreparedQueryTemplateArgs
    Query templating options. This is used to make a single prepared query respond to many different requests
    token str
    The ACL token to use when saving the prepared query. This overrides the token that the agent provides by default.

    Deprecated:The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

    service String
    The name of the service to query
    connect Boolean
    When true the prepared query will return connect proxy services for a queried service. Conditions such as tags in the prepared query will be matched against the proxy service. Defaults to false.
    datacenter String
    Specifies a WAN federated datacenter to forward the query to.
    dns Property Map
    Settings for controlling the DNS response details.
    failover Property Map
    Options for controlling behavior when no healthy nodes are available in the local DC.
    ignoreCheckIds List<String>
    Specifies a list of check IDs that should be ignored when filtering unhealthy instances. This is mostly useful in an emergency or as a temporary measure when a health check is found to be unreliable. Being able to ignore it in centrally-defined queries can be simpler than de-registering the check as an interim solution until the check can be fixed.
    name String
    The name of the prepared query. Used to identify the prepared query during requests. Can be specified as an empty string to configure the query as a catch-all.
    near String
    Allows specifying the name of a node to sort results near using Consul's distance sorting and network coordinates. The magic _agent value can be used to always sort nearest the node servicing the request.
    nodeMeta Map<String>
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.
    onlyPassing Boolean
    When true, the prepared query will only return nodes with passing health checks in the result.
    serviceMeta Map<String>
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to services with the given metadata values present.
    session String
    The name of the Consul session to tie this query's lifetime to. This is an advanced parameter that should not be used without a complete understanding of Consul sessions and the implications of their use (it is recommended to leave this blank in nearly all cases). If this parameter is omitted the query will not expire.
    storedToken String
    The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
    tags List<String>
    The list of required and/or disallowed tags. If a tag is in this list it must be present. If the tag is preceded with a "!" then it is disallowed.
    template Property Map
    Query templating options. This is used to make a single prepared query respond to many different requests
    token String
    The ACL token to use when saving the prepared query. This overrides the token that the agent provides by default.

    Deprecated:The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

    Outputs

    All input properties are implicitly available as output properties. Additionally, the PreparedQuery 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 PreparedQuery Resource

    Get an existing PreparedQuery 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?: PreparedQueryState, opts?: CustomResourceOptions): PreparedQuery
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            connect: Optional[bool] = None,
            datacenter: Optional[str] = None,
            dns: Optional[PreparedQueryDnsArgs] = None,
            failover: Optional[PreparedQueryFailoverArgs] = None,
            ignore_check_ids: Optional[Sequence[str]] = None,
            name: Optional[str] = None,
            near: Optional[str] = None,
            node_meta: Optional[Mapping[str, str]] = None,
            only_passing: Optional[bool] = None,
            service: Optional[str] = None,
            service_meta: Optional[Mapping[str, str]] = None,
            session: Optional[str] = None,
            stored_token: Optional[str] = None,
            tags: Optional[Sequence[str]] = None,
            template: Optional[PreparedQueryTemplateArgs] = None,
            token: Optional[str] = None) -> PreparedQuery
    func GetPreparedQuery(ctx *Context, name string, id IDInput, state *PreparedQueryState, opts ...ResourceOption) (*PreparedQuery, error)
    public static PreparedQuery Get(string name, Input<string> id, PreparedQueryState? state, CustomResourceOptions? opts = null)
    public static PreparedQuery get(String name, Output<String> id, PreparedQueryState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Connect bool
    When true the prepared query will return connect proxy services for a queried service. Conditions such as tags in the prepared query will be matched against the proxy service. Defaults to false.
    Datacenter string
    Specifies a WAN federated datacenter to forward the query to.
    Dns PreparedQueryDns
    Settings for controlling the DNS response details.
    Failover PreparedQueryFailover
    Options for controlling behavior when no healthy nodes are available in the local DC.
    IgnoreCheckIds List<string>
    Specifies a list of check IDs that should be ignored when filtering unhealthy instances. This is mostly useful in an emergency or as a temporary measure when a health check is found to be unreliable. Being able to ignore it in centrally-defined queries can be simpler than de-registering the check as an interim solution until the check can be fixed.
    Name string
    The name of the prepared query. Used to identify the prepared query during requests. Can be specified as an empty string to configure the query as a catch-all.
    Near string
    Allows specifying the name of a node to sort results near using Consul's distance sorting and network coordinates. The magic _agent value can be used to always sort nearest the node servicing the request.
    NodeMeta Dictionary<string, string>
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.
    OnlyPassing bool
    When true, the prepared query will only return nodes with passing health checks in the result.
    Service string
    The name of the service to query
    ServiceMeta Dictionary<string, string>
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to services with the given metadata values present.
    Session string
    The name of the Consul session to tie this query's lifetime to. This is an advanced parameter that should not be used without a complete understanding of Consul sessions and the implications of their use (it is recommended to leave this blank in nearly all cases). If this parameter is omitted the query will not expire.
    StoredToken string
    The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
    Tags List<string>
    The list of required and/or disallowed tags. If a tag is in this list it must be present. If the tag is preceded with a "!" then it is disallowed.
    Template PreparedQueryTemplate
    Query templating options. This is used to make a single prepared query respond to many different requests
    Token string
    The ACL token to use when saving the prepared query. This overrides the token that the agent provides by default.

    Deprecated:The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

    Connect bool
    When true the prepared query will return connect proxy services for a queried service. Conditions such as tags in the prepared query will be matched against the proxy service. Defaults to false.
    Datacenter string
    Specifies a WAN federated datacenter to forward the query to.
    Dns PreparedQueryDnsArgs
    Settings for controlling the DNS response details.
    Failover PreparedQueryFailoverArgs
    Options for controlling behavior when no healthy nodes are available in the local DC.
    IgnoreCheckIds []string
    Specifies a list of check IDs that should be ignored when filtering unhealthy instances. This is mostly useful in an emergency or as a temporary measure when a health check is found to be unreliable. Being able to ignore it in centrally-defined queries can be simpler than de-registering the check as an interim solution until the check can be fixed.
    Name string
    The name of the prepared query. Used to identify the prepared query during requests. Can be specified as an empty string to configure the query as a catch-all.
    Near string
    Allows specifying the name of a node to sort results near using Consul's distance sorting and network coordinates. The magic _agent value can be used to always sort nearest the node servicing the request.
    NodeMeta map[string]string
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.
    OnlyPassing bool
    When true, the prepared query will only return nodes with passing health checks in the result.
    Service string
    The name of the service to query
    ServiceMeta map[string]string
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to services with the given metadata values present.
    Session string
    The name of the Consul session to tie this query's lifetime to. This is an advanced parameter that should not be used without a complete understanding of Consul sessions and the implications of their use (it is recommended to leave this blank in nearly all cases). If this parameter is omitted the query will not expire.
    StoredToken string
    The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
    Tags []string
    The list of required and/or disallowed tags. If a tag is in this list it must be present. If the tag is preceded with a "!" then it is disallowed.
    Template PreparedQueryTemplateArgs
    Query templating options. This is used to make a single prepared query respond to many different requests
    Token string
    The ACL token to use when saving the prepared query. This overrides the token that the agent provides by default.

    Deprecated:The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

    connect Boolean
    When true the prepared query will return connect proxy services for a queried service. Conditions such as tags in the prepared query will be matched against the proxy service. Defaults to false.
    datacenter String
    Specifies a WAN federated datacenter to forward the query to.
    dns PreparedQueryDns
    Settings for controlling the DNS response details.
    failover PreparedQueryFailover
    Options for controlling behavior when no healthy nodes are available in the local DC.
    ignoreCheckIds List<String>
    Specifies a list of check IDs that should be ignored when filtering unhealthy instances. This is mostly useful in an emergency or as a temporary measure when a health check is found to be unreliable. Being able to ignore it in centrally-defined queries can be simpler than de-registering the check as an interim solution until the check can be fixed.
    name String
    The name of the prepared query. Used to identify the prepared query during requests. Can be specified as an empty string to configure the query as a catch-all.
    near String
    Allows specifying the name of a node to sort results near using Consul's distance sorting and network coordinates. The magic _agent value can be used to always sort nearest the node servicing the request.
    nodeMeta Map<String,String>
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.
    onlyPassing Boolean
    When true, the prepared query will only return nodes with passing health checks in the result.
    service String
    The name of the service to query
    serviceMeta Map<String,String>
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to services with the given metadata values present.
    session String
    The name of the Consul session to tie this query's lifetime to. This is an advanced parameter that should not be used without a complete understanding of Consul sessions and the implications of their use (it is recommended to leave this blank in nearly all cases). If this parameter is omitted the query will not expire.
    storedToken String
    The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
    tags List<String>
    The list of required and/or disallowed tags. If a tag is in this list it must be present. If the tag is preceded with a "!" then it is disallowed.
    template PreparedQueryTemplate
    Query templating options. This is used to make a single prepared query respond to many different requests
    token String
    The ACL token to use when saving the prepared query. This overrides the token that the agent provides by default.

    Deprecated:The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

    connect boolean
    When true the prepared query will return connect proxy services for a queried service. Conditions such as tags in the prepared query will be matched against the proxy service. Defaults to false.
    datacenter string
    Specifies a WAN federated datacenter to forward the query to.
    dns PreparedQueryDns
    Settings for controlling the DNS response details.
    failover PreparedQueryFailover
    Options for controlling behavior when no healthy nodes are available in the local DC.
    ignoreCheckIds string[]
    Specifies a list of check IDs that should be ignored when filtering unhealthy instances. This is mostly useful in an emergency or as a temporary measure when a health check is found to be unreliable. Being able to ignore it in centrally-defined queries can be simpler than de-registering the check as an interim solution until the check can be fixed.
    name string
    The name of the prepared query. Used to identify the prepared query during requests. Can be specified as an empty string to configure the query as a catch-all.
    near string
    Allows specifying the name of a node to sort results near using Consul's distance sorting and network coordinates. The magic _agent value can be used to always sort nearest the node servicing the request.
    nodeMeta {[key: string]: string}
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.
    onlyPassing boolean
    When true, the prepared query will only return nodes with passing health checks in the result.
    service string
    The name of the service to query
    serviceMeta {[key: string]: string}
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to services with the given metadata values present.
    session string
    The name of the Consul session to tie this query's lifetime to. This is an advanced parameter that should not be used without a complete understanding of Consul sessions and the implications of their use (it is recommended to leave this blank in nearly all cases). If this parameter is omitted the query will not expire.
    storedToken string
    The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
    tags string[]
    The list of required and/or disallowed tags. If a tag is in this list it must be present. If the tag is preceded with a "!" then it is disallowed.
    template PreparedQueryTemplate
    Query templating options. This is used to make a single prepared query respond to many different requests
    token string
    The ACL token to use when saving the prepared query. This overrides the token that the agent provides by default.

    Deprecated:The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

    connect bool
    When true the prepared query will return connect proxy services for a queried service. Conditions such as tags in the prepared query will be matched against the proxy service. Defaults to false.
    datacenter str
    Specifies a WAN federated datacenter to forward the query to.
    dns PreparedQueryDnsArgs
    Settings for controlling the DNS response details.
    failover PreparedQueryFailoverArgs
    Options for controlling behavior when no healthy nodes are available in the local DC.
    ignore_check_ids Sequence[str]
    Specifies a list of check IDs that should be ignored when filtering unhealthy instances. This is mostly useful in an emergency or as a temporary measure when a health check is found to be unreliable. Being able to ignore it in centrally-defined queries can be simpler than de-registering the check as an interim solution until the check can be fixed.
    name str
    The name of the prepared query. Used to identify the prepared query during requests. Can be specified as an empty string to configure the query as a catch-all.
    near str
    Allows specifying the name of a node to sort results near using Consul's distance sorting and network coordinates. The magic _agent value can be used to always sort nearest the node servicing the request.
    node_meta Mapping[str, str]
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.
    only_passing bool
    When true, the prepared query will only return nodes with passing health checks in the result.
    service str
    The name of the service to query
    service_meta Mapping[str, str]
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to services with the given metadata values present.
    session str
    The name of the Consul session to tie this query's lifetime to. This is an advanced parameter that should not be used without a complete understanding of Consul sessions and the implications of their use (it is recommended to leave this blank in nearly all cases). If this parameter is omitted the query will not expire.
    stored_token str
    The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
    tags Sequence[str]
    The list of required and/or disallowed tags. If a tag is in this list it must be present. If the tag is preceded with a "!" then it is disallowed.
    template PreparedQueryTemplateArgs
    Query templating options. This is used to make a single prepared query respond to many different requests
    token str
    The ACL token to use when saving the prepared query. This overrides the token that the agent provides by default.

    Deprecated:The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

    connect Boolean
    When true the prepared query will return connect proxy services for a queried service. Conditions such as tags in the prepared query will be matched against the proxy service. Defaults to false.
    datacenter String
    Specifies a WAN federated datacenter to forward the query to.
    dns Property Map
    Settings for controlling the DNS response details.
    failover Property Map
    Options for controlling behavior when no healthy nodes are available in the local DC.
    ignoreCheckIds List<String>
    Specifies a list of check IDs that should be ignored when filtering unhealthy instances. This is mostly useful in an emergency or as a temporary measure when a health check is found to be unreliable. Being able to ignore it in centrally-defined queries can be simpler than de-registering the check as an interim solution until the check can be fixed.
    name String
    The name of the prepared query. Used to identify the prepared query during requests. Can be specified as an empty string to configure the query as a catch-all.
    near String
    Allows specifying the name of a node to sort results near using Consul's distance sorting and network coordinates. The magic _agent value can be used to always sort nearest the node servicing the request.
    nodeMeta Map<String>
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.
    onlyPassing Boolean
    When true, the prepared query will only return nodes with passing health checks in the result.
    service String
    The name of the service to query
    serviceMeta Map<String>
    Specifies a list of user-defined key/value pairs that will be used for filtering the query results to services with the given metadata values present.
    session String
    The name of the Consul session to tie this query's lifetime to. This is an advanced parameter that should not be used without a complete understanding of Consul sessions and the implications of their use (it is recommended to leave this blank in nearly all cases). If this parameter is omitted the query will not expire.
    storedToken String
    The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
    tags List<String>
    The list of required and/or disallowed tags. If a tag is in this list it must be present. If the tag is preceded with a "!" then it is disallowed.
    template Property Map
    Query templating options. This is used to make a single prepared query respond to many different requests
    token String
    The ACL token to use when saving the prepared query. This overrides the token that the agent provides by default.

    Deprecated:The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

    Supporting Types

    PreparedQueryDns, PreparedQueryDnsArgs

    Ttl string
    The TTL to send when returning DNS results.
    Ttl string
    The TTL to send when returning DNS results.
    ttl String
    The TTL to send when returning DNS results.
    ttl string
    The TTL to send when returning DNS results.
    ttl str
    The TTL to send when returning DNS results.
    ttl String
    The TTL to send when returning DNS results.

    PreparedQueryFailover, PreparedQueryFailoverArgs

    Datacenters List<string>
    Remote datacenters to return results from.
    NearestN int
    Return results from this many datacenters, sorted in ascending order of estimated RTT.
    Targets List<PreparedQueryFailoverTarget>
    Specifies a sequential list of remote datacenters and cluster peers to failover to if there are no healthy service instances in the local datacenter. This option cannot be used with nearest_n or datacenters.
    Datacenters []string
    Remote datacenters to return results from.
    NearestN int
    Return results from this many datacenters, sorted in ascending order of estimated RTT.
    Targets []PreparedQueryFailoverTarget
    Specifies a sequential list of remote datacenters and cluster peers to failover to if there are no healthy service instances in the local datacenter. This option cannot be used with nearest_n or datacenters.
    datacenters List<String>
    Remote datacenters to return results from.
    nearestN Integer
    Return results from this many datacenters, sorted in ascending order of estimated RTT.
    targets List<PreparedQueryFailoverTarget>
    Specifies a sequential list of remote datacenters and cluster peers to failover to if there are no healthy service instances in the local datacenter. This option cannot be used with nearest_n or datacenters.
    datacenters string[]
    Remote datacenters to return results from.
    nearestN number
    Return results from this many datacenters, sorted in ascending order of estimated RTT.
    targets PreparedQueryFailoverTarget[]
    Specifies a sequential list of remote datacenters and cluster peers to failover to if there are no healthy service instances in the local datacenter. This option cannot be used with nearest_n or datacenters.
    datacenters Sequence[str]
    Remote datacenters to return results from.
    nearest_n int
    Return results from this many datacenters, sorted in ascending order of estimated RTT.
    targets Sequence[PreparedQueryFailoverTarget]
    Specifies a sequential list of remote datacenters and cluster peers to failover to if there are no healthy service instances in the local datacenter. This option cannot be used with nearest_n or datacenters.
    datacenters List<String>
    Remote datacenters to return results from.
    nearestN Number
    Return results from this many datacenters, sorted in ascending order of estimated RTT.
    targets List<Property Map>
    Specifies a sequential list of remote datacenters and cluster peers to failover to if there are no healthy service instances in the local datacenter. This option cannot be used with nearest_n or datacenters.

    PreparedQueryFailoverTarget, PreparedQueryFailoverTargetArgs

    Datacenter string
    Specifies a WAN federated datacenter to forward the query to.
    Peer string
    Specifies a cluster peer to use for failover.
    Datacenter string
    Specifies a WAN federated datacenter to forward the query to.
    Peer string
    Specifies a cluster peer to use for failover.
    datacenter String
    Specifies a WAN federated datacenter to forward the query to.
    peer String
    Specifies a cluster peer to use for failover.
    datacenter string
    Specifies a WAN federated datacenter to forward the query to.
    peer string
    Specifies a cluster peer to use for failover.
    datacenter str
    Specifies a WAN federated datacenter to forward the query to.
    peer str
    Specifies a cluster peer to use for failover.
    datacenter String
    Specifies a WAN federated datacenter to forward the query to.
    peer String
    Specifies a cluster peer to use for failover.

    PreparedQueryTemplate, PreparedQueryTemplateArgs

    Regexp string
    The regular expression to match with. When using name_prefix_match, this regex is applied against the query name.
    Type string
    The type of template matching to perform. Currently only name_prefix_match is supported.
    RemoveEmptyTags bool
    If set to true, will cause the tags list inside the service structure to be stripped of any empty strings.
    Regexp string
    The regular expression to match with. When using name_prefix_match, this regex is applied against the query name.
    Type string
    The type of template matching to perform. Currently only name_prefix_match is supported.
    RemoveEmptyTags bool
    If set to true, will cause the tags list inside the service structure to be stripped of any empty strings.
    regexp String
    The regular expression to match with. When using name_prefix_match, this regex is applied against the query name.
    type String
    The type of template matching to perform. Currently only name_prefix_match is supported.
    removeEmptyTags Boolean
    If set to true, will cause the tags list inside the service structure to be stripped of any empty strings.
    regexp string
    The regular expression to match with. When using name_prefix_match, this regex is applied against the query name.
    type string
    The type of template matching to perform. Currently only name_prefix_match is supported.
    removeEmptyTags boolean
    If set to true, will cause the tags list inside the service structure to be stripped of any empty strings.
    regexp str
    The regular expression to match with. When using name_prefix_match, this regex is applied against the query name.
    type str
    The type of template matching to perform. Currently only name_prefix_match is supported.
    remove_empty_tags bool
    If set to true, will cause the tags list inside the service structure to be stripped of any empty strings.
    regexp String
    The regular expression to match with. When using name_prefix_match, this regex is applied against the query name.
    type String
    The type of template matching to perform. Currently only name_prefix_match is supported.
    removeEmptyTags Boolean
    If set to true, will cause the tags list inside the service structure to be stripped of any empty strings.

    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.11.1 published on Friday, Jan 19, 2024 by Pulumi