1. Packages
  2. Opensearch Provider
  3. API Docs
  4. Script
opensearch 2.3.1 published on Monday, Apr 14, 2025 by opensearch-project

opensearch.Script

Explore with Pulumi AI

Provides an OpenSearch script resource.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as opensearch from "@pulumi/opensearch";

// Create a script
const testScript = new opensearch.Script("testScript", {
    lang: "painless",
    scriptId: "my_script",
    source: "Math.log(_score * 2) + params.my_modifier",
});
Copy
import pulumi
import pulumi_opensearch as opensearch

# Create a script
test_script = opensearch.Script("testScript",
    lang="painless",
    script_id="my_script",
    source="Math.log(_score * 2) + params.my_modifier")
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/opensearch/v2/opensearch"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// Create a script
		_, err := opensearch.NewScript(ctx, "testScript", &opensearch.ScriptArgs{
			Lang:     pulumi.String("painless"),
			ScriptId: pulumi.String("my_script"),
			Source:   pulumi.String("Math.log(_score * 2) + params.my_modifier"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Opensearch = Pulumi.Opensearch;

return await Deployment.RunAsync(() => 
{
    // Create a script
    var testScript = new Opensearch.Script("testScript", new()
    {
        Lang = "painless",
        ScriptId = "my_script",
        Source = "Math.log(_score * 2) + params.my_modifier",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.opensearch.Script;
import com.pulumi.opensearch.ScriptArgs;
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) {
        // Create a script
        var testScript = new Script("testScript", ScriptArgs.builder()
            .lang("painless")
            .scriptId("my_script")
            .source("Math.log(_score * 2) + params.my_modifier")
            .build());

    }
}
Copy
resources:
  # Create a script
  testScript:
    type: opensearch:Script
    properties:
      lang: painless
      scriptId: my_script
      source: Math.log(_score * 2) + params.my_modifier
Copy

Create Script Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Script(name: string, args: ScriptArgs, opts?: CustomResourceOptions);
@overload
def Script(resource_name: str,
           args: ScriptArgs,
           opts: Optional[ResourceOptions] = None)

@overload
def Script(resource_name: str,
           opts: Optional[ResourceOptions] = None,
           script_id: Optional[str] = None,
           source: Optional[str] = None,
           lang: Optional[str] = None,
           opensearch_script_id: Optional[str] = None)
func NewScript(ctx *Context, name string, args ScriptArgs, opts ...ResourceOption) (*Script, error)
public Script(string name, ScriptArgs args, CustomResourceOptions? opts = null)
public Script(String name, ScriptArgs args)
public Script(String name, ScriptArgs args, CustomResourceOptions options)
type: opensearch:Script
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ScriptArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. ScriptArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. ScriptArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ScriptArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ScriptArgs
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 scriptResource = new Opensearch.Script("scriptResource", new()
{
    ScriptId = "string",
    Source = "string",
    Lang = "string",
    OpensearchScriptId = "string",
});
Copy
example, err := opensearch.NewScript(ctx, "scriptResource", &opensearch.ScriptArgs{
	ScriptId:           pulumi.String("string"),
	Source:             pulumi.String("string"),
	Lang:               pulumi.String("string"),
	OpensearchScriptId: pulumi.String("string"),
})
Copy
var scriptResource = new Script("scriptResource", ScriptArgs.builder()
    .scriptId("string")
    .source("string")
    .lang("string")
    .opensearchScriptId("string")
    .build());
Copy
script_resource = opensearch.Script("scriptResource",
    script_id="string",
    source="string",
    lang="string",
    opensearch_script_id="string")
Copy
const scriptResource = new opensearch.Script("scriptResource", {
    scriptId: "string",
    source: "string",
    lang: "string",
    opensearchScriptId: "string",
});
Copy
type: opensearch:Script
properties:
    lang: string
    opensearchScriptId: string
    scriptId: string
    source: string
Copy

Script 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 Script resource accepts the following input properties:

ScriptId This property is required. string
Identifier for the stored script. Must be unique within the cluster.
Source This property is required. string
The source of the stored script
Lang string
Specifies the language the script is written in. Defaults to painless.
OpensearchScriptId string
The ID of this resource.
ScriptId This property is required. string
Identifier for the stored script. Must be unique within the cluster.
Source This property is required. string
The source of the stored script
Lang string
Specifies the language the script is written in. Defaults to painless.
OpensearchScriptId string
The ID of this resource.
scriptId This property is required. String
Identifier for the stored script. Must be unique within the cluster.
source This property is required. String
The source of the stored script
lang String
Specifies the language the script is written in. Defaults to painless.
opensearchScriptId String
The ID of this resource.
scriptId This property is required. string
Identifier for the stored script. Must be unique within the cluster.
source This property is required. string
The source of the stored script
lang string
Specifies the language the script is written in. Defaults to painless.
opensearchScriptId string
The ID of this resource.
script_id This property is required. str
Identifier for the stored script. Must be unique within the cluster.
source This property is required. str
The source of the stored script
lang str
Specifies the language the script is written in. Defaults to painless.
opensearch_script_id str
The ID of this resource.
scriptId This property is required. String
Identifier for the stored script. Must be unique within the cluster.
source This property is required. String
The source of the stored script
lang String
Specifies the language the script is written in. Defaults to painless.
opensearchScriptId String
The ID of this resource.

Outputs

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

Get an existing Script 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?: ScriptState, opts?: CustomResourceOptions): Script
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        lang: Optional[str] = None,
        opensearch_script_id: Optional[str] = None,
        script_id: Optional[str] = None,
        source: Optional[str] = None) -> Script
func GetScript(ctx *Context, name string, id IDInput, state *ScriptState, opts ...ResourceOption) (*Script, error)
public static Script Get(string name, Input<string> id, ScriptState? state, CustomResourceOptions? opts = null)
public static Script get(String name, Output<String> id, ScriptState state, CustomResourceOptions options)
resources:  _:    type: opensearch:Script    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
Lang string
Specifies the language the script is written in. Defaults to painless.
OpensearchScriptId string
The ID of this resource.
ScriptId string
Identifier for the stored script. Must be unique within the cluster.
Source string
The source of the stored script
Lang string
Specifies the language the script is written in. Defaults to painless.
OpensearchScriptId string
The ID of this resource.
ScriptId string
Identifier for the stored script. Must be unique within the cluster.
Source string
The source of the stored script
lang String
Specifies the language the script is written in. Defaults to painless.
opensearchScriptId String
The ID of this resource.
scriptId String
Identifier for the stored script. Must be unique within the cluster.
source String
The source of the stored script
lang string
Specifies the language the script is written in. Defaults to painless.
opensearchScriptId string
The ID of this resource.
scriptId string
Identifier for the stored script. Must be unique within the cluster.
source string
The source of the stored script
lang str
Specifies the language the script is written in. Defaults to painless.
opensearch_script_id str
The ID of this resource.
script_id str
Identifier for the stored script. Must be unique within the cluster.
source str
The source of the stored script
lang String
Specifies the language the script is written in. Defaults to painless.
opensearchScriptId String
The ID of this resource.
scriptId String
Identifier for the stored script. Must be unique within the cluster.
source String
The source of the stored script

Import

$ pulumi import opensearch:index/script:Script test_script my_script
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
opensearch opensearch-project/terraform-provider-opensearch
License
Notes
This Pulumi package is based on the opensearch Terraform Provider.