consul.PreparedQuery
Explore with Pulumi AI
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 astags
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
Prepared
Query Dns Settings for controlling the DNS response details.
- Failover
Prepared
Query Failover Options for controlling behavior when no healthy nodes are available in the local DC.
- Ignore
Check List<string>Ids 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.- Node
Meta 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.
- Only
Passing bool When
true
, the prepared query will only return nodes with passing health checks in the result.- Service
Meta 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.
- Stored
Token string The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
- 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
Prepared
Query Template 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.
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 astags
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
Prepared
Query Dns Args Settings for controlling the DNS response details.
- Failover
Prepared
Query Failover Args Options for controlling behavior when no healthy nodes are available in the local DC.
- Ignore
Check []stringIds 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.- Node
Meta 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.
- Only
Passing bool When
true
, the prepared query will only return nodes with passing health checks in the result.- Service
Meta 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.
- Stored
Token string The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
- []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
Prepared
Query Template Args 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.
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 astags
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
Prepared
Query Dns Settings for controlling the DNS response details.
- failover
Prepared
Query Failover Options for controlling behavior when no healthy nodes are available in the local DC.
- ignore
Check List<String>Ids 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.- node
Meta 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.
- only
Passing Boolean When
true
, the prepared query will only return nodes with passing health checks in the result.- service
Meta 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.
- stored
Token String The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
- 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
Prepared
Query Template 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.
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 astags
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
Prepared
Query Dns Settings for controlling the DNS response details.
- failover
Prepared
Query Failover Options for controlling behavior when no healthy nodes are available in the local DC.
- ignore
Check string[]Ids 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.- node
Meta {[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.
- only
Passing boolean When
true
, the prepared query will only return nodes with passing health checks in the result.- service
Meta {[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.
- stored
Token string The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
- 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
Prepared
Query Template 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.
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 astags
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
Prepared
Query Dns Args Settings for controlling the DNS response details.
- failover
Prepared
Query Failover Args Options for controlling behavior when no healthy nodes are available in the local DC.
- ignore_
check_ Sequence[str]ids 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.
- 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
Prepared
Query Template Args 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.
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 astags
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.
- ignore
Check List<String>Ids 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.- node
Meta 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.
- only
Passing Boolean When
true
, the prepared query will only return nodes with passing health checks in the result.- service
Meta 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.
- stored
Token String The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
- 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.
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.
- Connect bool
When
true
the prepared query will return connect proxy services for a queried service. Conditions such astags
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
Prepared
Query Dns Settings for controlling the DNS response details.
- Failover
Prepared
Query Failover Options for controlling behavior when no healthy nodes are available in the local DC.
- Ignore
Check List<string>Ids 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.- Node
Meta 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.
- Only
Passing 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
- Service
Meta 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.
- Stored
Token string The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
- 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
Prepared
Query Template 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.
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 astags
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
Prepared
Query Dns Args Settings for controlling the DNS response details.
- Failover
Prepared
Query Failover Args Options for controlling behavior when no healthy nodes are available in the local DC.
- Ignore
Check []stringIds 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.- Node
Meta 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.
- Only
Passing 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
- Service
Meta 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.
- Stored
Token string The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
- []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
Prepared
Query Template Args 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.
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 astags
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
Prepared
Query Dns Settings for controlling the DNS response details.
- failover
Prepared
Query Failover Options for controlling behavior when no healthy nodes are available in the local DC.
- ignore
Check List<String>Ids 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.- node
Meta 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.
- only
Passing 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
- service
Meta 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.
- stored
Token String The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
- 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
Prepared
Query Template 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.
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 astags
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
Prepared
Query Dns Settings for controlling the DNS response details.
- failover
Prepared
Query Failover Options for controlling behavior when no healthy nodes are available in the local DC.
- ignore
Check string[]Ids 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.- node
Meta {[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.
- only
Passing 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
- service
Meta {[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.
- stored
Token string The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
- 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
Prepared
Query Template 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.
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 astags
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
Prepared
Query Dns Args Settings for controlling the DNS response details.
- failover
Prepared
Query Failover Args Options for controlling behavior when no healthy nodes are available in the local DC.
- ignore_
check_ Sequence[str]ids 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.
- 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
Prepared
Query Template Args 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.
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 astags
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.
- ignore
Check List<String>Ids 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.- node
Meta 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.
- only
Passing 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
- service
Meta 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.
- stored
Token String The ACL token to store with the prepared query. This token will be used by default whenever the query is executed.
- 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.
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.
- Nearest
N int Return results from this many datacenters, sorted in ascending order of estimated RTT.
- Targets
List<Prepared
Query Failover Target> 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
ordatacenters
.
- Datacenters []string
Remote datacenters to return results from.
- Nearest
N int Return results from this many datacenters, sorted in ascending order of estimated RTT.
- Targets
[]Prepared
Query Failover Target 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
ordatacenters
.
- datacenters List<String>
Remote datacenters to return results from.
- nearest
N Integer Return results from this many datacenters, sorted in ascending order of estimated RTT.
- targets
List<Prepared
Query Failover Target> 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
ordatacenters
.
- datacenters string[]
Remote datacenters to return results from.
- nearest
N number Return results from this many datacenters, sorted in ascending order of estimated RTT.
- targets
Prepared
Query Failover Target[] 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
ordatacenters
.
- 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[Prepared
Query Failover Target] 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
ordatacenters
.
- datacenters List<String>
Remote datacenters to return results from.
- nearest
N 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
ordatacenters
.
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.- 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.- 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.- 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.- 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.- 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.- 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.