elasticstack.ElasticsearchScript
Explore with Pulumi AI
Creates or updates a stored script or search template. See https://www.elastic.co/guide/en/elasticsearch/reference/current/create-stored-script-api.html
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as elasticstack from "@pulumi/elasticstack";
const myScript = new elasticstack.ElasticsearchScript("myScript", {
scriptId: "my_script",
lang: "painless",
source: "Math.log(_score * 2) + params['my_modifier']",
context: "score",
});
const mySearchTemplate = new elasticstack.ElasticsearchScript("mySearchTemplate", {
scriptId: "my_search_template",
lang: "mustache",
source: JSON.stringify({
query: {
match: {
message: "{{query_string}}",
},
},
from: "{{from}}",
size: "{{size}}",
}),
params: JSON.stringify({
query_string: "My query string",
}),
});
import pulumi
import json
import pulumi_elasticstack as elasticstack
my_script = elasticstack.ElasticsearchScript("myScript",
script_id="my_script",
lang="painless",
source="Math.log(_score * 2) + params['my_modifier']",
context="score")
my_search_template = elasticstack.ElasticsearchScript("mySearchTemplate",
script_id="my_search_template",
lang="mustache",
source=json.dumps({
"query": {
"match": {
"message": "{{query_string}}",
},
},
"from": "{{from}}",
"size": "{{size}}",
}),
params=json.dumps({
"query_string": "My query string",
}))
package main
import (
"encoding/json"
"github.com/pulumi/pulumi-terraform-provider/sdks/go/elasticstack/elasticstack"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := elasticstack.NewElasticsearchScript(ctx, "myScript", &elasticstack.ElasticsearchScriptArgs{
ScriptId: pulumi.String("my_script"),
Lang: pulumi.String("painless"),
Source: pulumi.String("Math.log(_score * 2) + params['my_modifier']"),
Context: pulumi.String("score"),
})
if err != nil {
return err
}
tmpJSON0, err := json.Marshal(map[string]interface{}{
"query": map[string]interface{}{
"match": map[string]interface{}{
"message": "{{query_string}}",
},
},
"from": "{{from}}",
"size": "{{size}}",
})
if err != nil {
return err
}
json0 := string(tmpJSON0)
tmpJSON1, err := json.Marshal(map[string]interface{}{
"query_string": "My query string",
})
if err != nil {
return err
}
json1 := string(tmpJSON1)
_, err = elasticstack.NewElasticsearchScript(ctx, "mySearchTemplate", &elasticstack.ElasticsearchScriptArgs{
ScriptId: pulumi.String("my_search_template"),
Lang: pulumi.String("mustache"),
Source: pulumi.String(json0),
Params: pulumi.String(json1),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Elasticstack = Pulumi.Elasticstack;
return await Deployment.RunAsync(() =>
{
var myScript = new Elasticstack.ElasticsearchScript("myScript", new()
{
ScriptId = "my_script",
Lang = "painless",
Source = "Math.log(_score * 2) + params['my_modifier']",
Context = "score",
});
var mySearchTemplate = new Elasticstack.ElasticsearchScript("mySearchTemplate", new()
{
ScriptId = "my_search_template",
Lang = "mustache",
Source = JsonSerializer.Serialize(new Dictionary<string, object?>
{
["query"] = new Dictionary<string, object?>
{
["match"] = new Dictionary<string, object?>
{
["message"] = "{{query_string}}",
},
},
["from"] = "{{from}}",
["size"] = "{{size}}",
}),
Params = JsonSerializer.Serialize(new Dictionary<string, object?>
{
["query_string"] = "My query string",
}),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.elasticstack.ElasticsearchScript;
import com.pulumi.elasticstack.ElasticsearchScriptArgs;
import static com.pulumi.codegen.internal.Serialization.*;
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 myScript = new ElasticsearchScript("myScript", ElasticsearchScriptArgs.builder()
.scriptId("my_script")
.lang("painless")
.source("Math.log(_score * 2) + params['my_modifier']")
.context("score")
.build());
var mySearchTemplate = new ElasticsearchScript("mySearchTemplate", ElasticsearchScriptArgs.builder()
.scriptId("my_search_template")
.lang("mustache")
.source(serializeJson(
jsonObject(
jsonProperty("query", jsonObject(
jsonProperty("match", jsonObject(
jsonProperty("message", "{{query_string}}")
))
)),
jsonProperty("from", "{{from}}"),
jsonProperty("size", "{{size}}")
)))
.params(serializeJson(
jsonObject(
jsonProperty("query_string", "My query string")
)))
.build());
}
}
resources:
myScript:
type: elasticstack:ElasticsearchScript
properties:
scriptId: my_script
lang: painless
source: Math.log(_score * 2) + params['my_modifier']
context: score
mySearchTemplate:
type: elasticstack:ElasticsearchScript
properties:
scriptId: my_search_template
lang: mustache
source:
fn::toJSON:
query:
match:
message: '{{query_string}}'
from: '{{from}}'
size: '{{size}}'
params:
fn::toJSON:
query_string: My query string
Create ElasticsearchScript Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ElasticsearchScript(name: string, args: ElasticsearchScriptArgs, opts?: CustomResourceOptions);
@overload
def ElasticsearchScript(resource_name: str,
args: ElasticsearchScriptArgs,
opts: Optional[ResourceOptions] = None)
@overload
def ElasticsearchScript(resource_name: str,
opts: Optional[ResourceOptions] = None,
lang: Optional[str] = None,
script_id: Optional[str] = None,
source: Optional[str] = None,
context: Optional[str] = None,
elasticsearch_connection: Optional[ElasticsearchScriptElasticsearchConnectionArgs] = None,
elasticsearch_script_id: Optional[str] = None,
params: Optional[str] = None)
func NewElasticsearchScript(ctx *Context, name string, args ElasticsearchScriptArgs, opts ...ResourceOption) (*ElasticsearchScript, error)
public ElasticsearchScript(string name, ElasticsearchScriptArgs args, CustomResourceOptions? opts = null)
public ElasticsearchScript(String name, ElasticsearchScriptArgs args)
public ElasticsearchScript(String name, ElasticsearchScriptArgs args, CustomResourceOptions options)
type: elasticstack:ElasticsearchScript
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args ElasticsearchScriptArgs
- 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 ElasticsearchScriptArgs
- 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 ElasticsearchScriptArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ElasticsearchScriptArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ElasticsearchScriptArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var elasticsearchScriptResource = new Elasticstack.ElasticsearchScript("elasticsearchScriptResource", new()
{
Lang = "string",
ScriptId = "string",
Source = "string",
Context = "string",
ElasticsearchScriptId = "string",
Params = "string",
});
example, err := elasticstack.NewElasticsearchScript(ctx, "elasticsearchScriptResource", &elasticstack.ElasticsearchScriptArgs{
Lang: pulumi.String("string"),
ScriptId: pulumi.String("string"),
Source: pulumi.String("string"),
Context: pulumi.String("string"),
ElasticsearchScriptId: pulumi.String("string"),
Params: pulumi.String("string"),
})
var elasticsearchScriptResource = new ElasticsearchScript("elasticsearchScriptResource", ElasticsearchScriptArgs.builder()
.lang("string")
.scriptId("string")
.source("string")
.context("string")
.elasticsearchScriptId("string")
.params("string")
.build());
elasticsearch_script_resource = elasticstack.ElasticsearchScript("elasticsearchScriptResource",
lang="string",
script_id="string",
source="string",
context="string",
elasticsearch_script_id="string",
params="string")
const elasticsearchScriptResource = new elasticstack.ElasticsearchScript("elasticsearchScriptResource", {
lang: "string",
scriptId: "string",
source: "string",
context: "string",
elasticsearchScriptId: "string",
params: "string",
});
type: elasticstack:ElasticsearchScript
properties:
context: string
elasticsearchScriptId: string
lang: string
params: string
scriptId: string
source: string
ElasticsearchScript Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The ElasticsearchScript resource accepts the following input properties:
- Lang string
- Script language. For search templates, use
mustache
. - Script
Id string - Identifier for the stored script. Must be unique within the cluster.
- Source string
- For scripts, a string containing the script. For search templates, an object containing the search template.
- Context string
- Context in which the script or search template should run.
- Elasticsearch
Connection ElasticsearchScript Elasticsearch Connection - Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead.
- Elasticsearch
Script stringId - The ID of this resource.
- Params string
- Parameters for the script or search template.
- Lang string
- Script language. For search templates, use
mustache
. - Script
Id string - Identifier for the stored script. Must be unique within the cluster.
- Source string
- For scripts, a string containing the script. For search templates, an object containing the search template.
- Context string
- Context in which the script or search template should run.
- Elasticsearch
Connection ElasticsearchScript Elasticsearch Connection Args - Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead.
- Elasticsearch
Script stringId - The ID of this resource.
- Params string
- Parameters for the script or search template.
- lang String
- Script language. For search templates, use
mustache
. - script
Id String - Identifier for the stored script. Must be unique within the cluster.
- source String
- For scripts, a string containing the script. For search templates, an object containing the search template.
- context String
- Context in which the script or search template should run.
- elasticsearch
Connection ElasticsearchScript Elasticsearch Connection - Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead.
- elasticsearch
Script StringId - The ID of this resource.
- params String
- Parameters for the script or search template.
- lang string
- Script language. For search templates, use
mustache
. - script
Id string - Identifier for the stored script. Must be unique within the cluster.
- source string
- For scripts, a string containing the script. For search templates, an object containing the search template.
- context string
- Context in which the script or search template should run.
- elasticsearch
Connection ElasticsearchScript Elasticsearch Connection - Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead.
- elasticsearch
Script stringId - The ID of this resource.
- params string
- Parameters for the script or search template.
- lang str
- Script language. For search templates, use
mustache
. - script_
id str - Identifier for the stored script. Must be unique within the cluster.
- source str
- For scripts, a string containing the script. For search templates, an object containing the search template.
- context str
- Context in which the script or search template should run.
- elasticsearch_
connection ElasticsearchScript Elasticsearch Connection Args - Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead.
- elasticsearch_
script_ strid - The ID of this resource.
- params str
- Parameters for the script or search template.
- lang String
- Script language. For search templates, use
mustache
. - script
Id String - Identifier for the stored script. Must be unique within the cluster.
- source String
- For scripts, a string containing the script. For search templates, an object containing the search template.
- context String
- Context in which the script or search template should run.
- elasticsearch
Connection Property Map - Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead.
- elasticsearch
Script StringId - The ID of this resource.
- params String
- Parameters for the script or search template.
Outputs
All input properties are implicitly available as output properties. Additionally, the ElasticsearchScript 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 ElasticsearchScript Resource
Get an existing ElasticsearchScript 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?: ElasticsearchScriptState, opts?: CustomResourceOptions): ElasticsearchScript
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
context: Optional[str] = None,
elasticsearch_connection: Optional[ElasticsearchScriptElasticsearchConnectionArgs] = None,
elasticsearch_script_id: Optional[str] = None,
lang: Optional[str] = None,
params: Optional[str] = None,
script_id: Optional[str] = None,
source: Optional[str] = None) -> ElasticsearchScript
func GetElasticsearchScript(ctx *Context, name string, id IDInput, state *ElasticsearchScriptState, opts ...ResourceOption) (*ElasticsearchScript, error)
public static ElasticsearchScript Get(string name, Input<string> id, ElasticsearchScriptState? state, CustomResourceOptions? opts = null)
public static ElasticsearchScript get(String name, Output<String> id, ElasticsearchScriptState state, CustomResourceOptions options)
resources: _: type: elasticstack:ElasticsearchScript get: id: ${id}
- 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.
- Context string
- Context in which the script or search template should run.
- Elasticsearch
Connection ElasticsearchScript Elasticsearch Connection - Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead.
- Elasticsearch
Script stringId - The ID of this resource.
- Lang string
- Script language. For search templates, use
mustache
. - Params string
- Parameters for the script or search template.
- Script
Id string - Identifier for the stored script. Must be unique within the cluster.
- Source string
- For scripts, a string containing the script. For search templates, an object containing the search template.
- Context string
- Context in which the script or search template should run.
- Elasticsearch
Connection ElasticsearchScript Elasticsearch Connection Args - Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead.
- Elasticsearch
Script stringId - The ID of this resource.
- Lang string
- Script language. For search templates, use
mustache
. - Params string
- Parameters for the script or search template.
- Script
Id string - Identifier for the stored script. Must be unique within the cluster.
- Source string
- For scripts, a string containing the script. For search templates, an object containing the search template.
- context String
- Context in which the script or search template should run.
- elasticsearch
Connection ElasticsearchScript Elasticsearch Connection - Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead.
- elasticsearch
Script StringId - The ID of this resource.
- lang String
- Script language. For search templates, use
mustache
. - params String
- Parameters for the script or search template.
- script
Id String - Identifier for the stored script. Must be unique within the cluster.
- source String
- For scripts, a string containing the script. For search templates, an object containing the search template.
- context string
- Context in which the script or search template should run.
- elasticsearch
Connection ElasticsearchScript Elasticsearch Connection - Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead.
- elasticsearch
Script stringId - The ID of this resource.
- lang string
- Script language. For search templates, use
mustache
. - params string
- Parameters for the script or search template.
- script
Id string - Identifier for the stored script. Must be unique within the cluster.
- source string
- For scripts, a string containing the script. For search templates, an object containing the search template.
- context str
- Context in which the script or search template should run.
- elasticsearch_
connection ElasticsearchScript Elasticsearch Connection Args - Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead.
- elasticsearch_
script_ strid - The ID of this resource.
- lang str
- Script language. For search templates, use
mustache
. - params str
- Parameters for the script or search template.
- script_
id str - Identifier for the stored script. Must be unique within the cluster.
- source str
- For scripts, a string containing the script. For search templates, an object containing the search template.
- context String
- Context in which the script or search template should run.
- elasticsearch
Connection Property Map - Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead.
- elasticsearch
Script StringId - The ID of this resource.
- lang String
- Script language. For search templates, use
mustache
. - params String
- Parameters for the script or search template.
- script
Id String - Identifier for the stored script. Must be unique within the cluster.
- source String
- For scripts, a string containing the script. For search templates, an object containing the search template.
Supporting Types
ElasticsearchScriptElasticsearchConnection, ElasticsearchScriptElasticsearchConnectionArgs
- Api
Key string - API Key to use for authentication to Elasticsearch
- Bearer
Token string - Bearer Token to use for authentication to Elasticsearch
- Ca
Data string - PEM-encoded custom Certificate Authority certificate
- Ca
File string - Path to a custom Certificate Authority certificate
- Cert
Data string - PEM encoded certificate for client auth
- Cert
File string - Path to a file containing the PEM encoded certificate for client auth
- Endpoints List<string>
- Es
Client stringAuthentication - ES Client Authentication field to be used with the JWT token
- Insecure bool
- Disable TLS certificate validation
- Key
Data string - PEM encoded private key for client auth
- Key
File string - Path to a file containing the PEM encoded private key for client auth
- Password string
- Password to use for API authentication to Elasticsearch.
- Username string
- Username to use for API authentication to Elasticsearch.
- Api
Key string - API Key to use for authentication to Elasticsearch
- Bearer
Token string - Bearer Token to use for authentication to Elasticsearch
- Ca
Data string - PEM-encoded custom Certificate Authority certificate
- Ca
File string - Path to a custom Certificate Authority certificate
- Cert
Data string - PEM encoded certificate for client auth
- Cert
File string - Path to a file containing the PEM encoded certificate for client auth
- Endpoints []string
- Es
Client stringAuthentication - ES Client Authentication field to be used with the JWT token
- Insecure bool
- Disable TLS certificate validation
- Key
Data string - PEM encoded private key for client auth
- Key
File string - Path to a file containing the PEM encoded private key for client auth
- Password string
- Password to use for API authentication to Elasticsearch.
- Username string
- Username to use for API authentication to Elasticsearch.
- api
Key String - API Key to use for authentication to Elasticsearch
- bearer
Token String - Bearer Token to use for authentication to Elasticsearch
- ca
Data String - PEM-encoded custom Certificate Authority certificate
- ca
File String - Path to a custom Certificate Authority certificate
- cert
Data String - PEM encoded certificate for client auth
- cert
File String - Path to a file containing the PEM encoded certificate for client auth
- endpoints List<String>
- es
Client StringAuthentication - ES Client Authentication field to be used with the JWT token
- insecure Boolean
- Disable TLS certificate validation
- key
Data String - PEM encoded private key for client auth
- key
File String - Path to a file containing the PEM encoded private key for client auth
- password String
- Password to use for API authentication to Elasticsearch.
- username String
- Username to use for API authentication to Elasticsearch.
- api
Key string - API Key to use for authentication to Elasticsearch
- bearer
Token string - Bearer Token to use for authentication to Elasticsearch
- ca
Data string - PEM-encoded custom Certificate Authority certificate
- ca
File string - Path to a custom Certificate Authority certificate
- cert
Data string - PEM encoded certificate for client auth
- cert
File string - Path to a file containing the PEM encoded certificate for client auth
- endpoints string[]
- es
Client stringAuthentication - ES Client Authentication field to be used with the JWT token
- insecure boolean
- Disable TLS certificate validation
- key
Data string - PEM encoded private key for client auth
- key
File string - Path to a file containing the PEM encoded private key for client auth
- password string
- Password to use for API authentication to Elasticsearch.
- username string
- Username to use for API authentication to Elasticsearch.
- api_
key str - API Key to use for authentication to Elasticsearch
- bearer_
token str - Bearer Token to use for authentication to Elasticsearch
- ca_
data str - PEM-encoded custom Certificate Authority certificate
- ca_
file str - Path to a custom Certificate Authority certificate
- cert_
data str - PEM encoded certificate for client auth
- cert_
file str - Path to a file containing the PEM encoded certificate for client auth
- endpoints Sequence[str]
- es_
client_ strauthentication - ES Client Authentication field to be used with the JWT token
- insecure bool
- Disable TLS certificate validation
- key_
data str - PEM encoded private key for client auth
- key_
file str - Path to a file containing the PEM encoded private key for client auth
- password str
- Password to use for API authentication to Elasticsearch.
- username str
- Username to use for API authentication to Elasticsearch.
- api
Key String - API Key to use for authentication to Elasticsearch
- bearer
Token String - Bearer Token to use for authentication to Elasticsearch
- ca
Data String - PEM-encoded custom Certificate Authority certificate
- ca
File String - Path to a custom Certificate Authority certificate
- cert
Data String - PEM encoded certificate for client auth
- cert
File String - Path to a file containing the PEM encoded certificate for client auth
- endpoints List<String>
- es
Client StringAuthentication - ES Client Authentication field to be used with the JWT token
- insecure Boolean
- Disable TLS certificate validation
- key
Data String - PEM encoded private key for client auth
- key
File String - Path to a file containing the PEM encoded private key for client auth
- password String
- Password to use for API authentication to Elasticsearch.
- username String
- Username to use for API authentication to Elasticsearch.
Import
$ pulumi import elasticstack:index/elasticsearchScript:ElasticsearchScript my_script <cluster_uuid>/<script id>
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- elasticstack elastic/terraform-provider-elasticstack
- License
- Notes
- This Pulumi package is based on the
elasticstack
Terraform Provider.