opensearch.IndexTemplate
Explore with Pulumi AI
Provides an OpenSearch index template resource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as opensearch from "@pulumi/opensearch";
// Create an index template
const template1 = new opensearch.IndexTemplate("template1", {body: `{
"index_patterns": [
"logs-2020-01-*"
],
"template": {
"aliases": {
"my_logs": {}
},
"settings": {
"index": {
"number_of_shards": "2",
"number_of_replicas": "1"
}
},
"mappings": {
"properties": {
"timestamp": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"value": {
"type": "double"
}
}
}
}
}
`});
import pulumi
import pulumi_opensearch as opensearch
# Create an index template
template1 = opensearch.IndexTemplate("template1", body="""{
"index_patterns": [
"logs-2020-01-*"
],
"template": {
"aliases": {
"my_logs": {}
},
"settings": {
"index": {
"number_of_shards": "2",
"number_of_replicas": "1"
}
},
"mappings": {
"properties": {
"timestamp": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"value": {
"type": "double"
}
}
}
}
}
""")
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 an index template
_, err := opensearch.NewIndexTemplate(ctx, "template1", &opensearch.IndexTemplateArgs{
Body: pulumi.String(`{
"index_patterns": [
"logs-2020-01-*"
],
"template": {
"aliases": {
"my_logs": {}
},
"settings": {
"index": {
"number_of_shards": "2",
"number_of_replicas": "1"
}
},
"mappings": {
"properties": {
"timestamp": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"value": {
"type": "double"
}
}
}
}
}
`),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Opensearch = Pulumi.Opensearch;
return await Deployment.RunAsync(() =>
{
// Create an index template
var template1 = new Opensearch.IndexTemplate("template1", new()
{
Body = @"{
""index_patterns"": [
""logs-2020-01-*""
],
""template"": {
""aliases"": {
""my_logs"": {}
},
""settings"": {
""index"": {
""number_of_shards"": ""2"",
""number_of_replicas"": ""1""
}
},
""mappings"": {
""properties"": {
""timestamp"": {
""type"": ""date"",
""format"": ""yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis""
},
""value"": {
""type"": ""double""
}
}
}
}
}
",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.opensearch.IndexTemplate;
import com.pulumi.opensearch.IndexTemplateArgs;
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 an index template
var template1 = new IndexTemplate("template1", IndexTemplateArgs.builder()
.body("""
{
"index_patterns": [
"logs-2020-01-*"
],
"template": {
"aliases": {
"my_logs": {}
},
"settings": {
"index": {
"number_of_shards": "2",
"number_of_replicas": "1"
}
},
"mappings": {
"properties": {
"timestamp": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"value": {
"type": "double"
}
}
}
}
}
""")
.build());
}
}
resources:
# Create an index template
template1:
type: opensearch:IndexTemplate
properties:
body: |+
{
"index_patterns": [
"logs-2020-01-*"
],
"template": {
"aliases": {
"my_logs": {}
},
"settings": {
"index": {
"number_of_shards": "2",
"number_of_replicas": "1"
}
},
"mappings": {
"properties": {
"timestamp": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"value": {
"type": "double"
}
}
}
}
}
Create IndexTemplate Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new IndexTemplate(name: string, args: IndexTemplateArgs, opts?: CustomResourceOptions);
@overload
def IndexTemplate(resource_name: str,
args: IndexTemplateArgs,
opts: Optional[ResourceOptions] = None)
@overload
def IndexTemplate(resource_name: str,
opts: Optional[ResourceOptions] = None,
body: Optional[str] = None,
index_template_id: Optional[str] = None,
name: Optional[str] = None)
func NewIndexTemplate(ctx *Context, name string, args IndexTemplateArgs, opts ...ResourceOption) (*IndexTemplate, error)
public IndexTemplate(string name, IndexTemplateArgs args, CustomResourceOptions? opts = null)
public IndexTemplate(String name, IndexTemplateArgs args)
public IndexTemplate(String name, IndexTemplateArgs args, CustomResourceOptions options)
type: opensearch:IndexTemplate
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 IndexTemplateArgs
- 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 IndexTemplateArgs
- 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 IndexTemplateArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args IndexTemplateArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args IndexTemplateArgs
- 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 indexTemplateResource = new Opensearch.IndexTemplate("indexTemplateResource", new()
{
Body = "string",
IndexTemplateId = "string",
Name = "string",
});
example, err := opensearch.NewIndexTemplate(ctx, "indexTemplateResource", &opensearch.IndexTemplateArgs{
Body: pulumi.String("string"),
IndexTemplateId: pulumi.String("string"),
Name: pulumi.String("string"),
})
var indexTemplateResource = new IndexTemplate("indexTemplateResource", IndexTemplateArgs.builder()
.body("string")
.indexTemplateId("string")
.name("string")
.build());
index_template_resource = opensearch.IndexTemplate("indexTemplateResource",
body="string",
index_template_id="string",
name="string")
const indexTemplateResource = new opensearch.IndexTemplate("indexTemplateResource", {
body: "string",
indexTemplateId: "string",
name: "string",
});
type: opensearch:IndexTemplate
properties:
body: string
indexTemplateId: string
name: string
IndexTemplate 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 IndexTemplate resource accepts the following input properties:
- Body string
- The JSON body of the index template.
- Index
Template stringId - The ID of this resource.
- Name string
- The name of the index template.
- Body string
- The JSON body of the index template.
- Index
Template stringId - The ID of this resource.
- Name string
- The name of the index template.
- body String
- The JSON body of the index template.
- index
Template StringId - The ID of this resource.
- name String
- The name of the index template.
- body string
- The JSON body of the index template.
- index
Template stringId - The ID of this resource.
- name string
- The name of the index template.
- body str
- The JSON body of the index template.
- index_
template_ strid - The ID of this resource.
- name str
- The name of the index template.
- body String
- The JSON body of the index template.
- index
Template StringId - The ID of this resource.
- name String
- The name of the index template.
Outputs
All input properties are implicitly available as output properties. Additionally, the IndexTemplate 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 IndexTemplate Resource
Get an existing IndexTemplate 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?: IndexTemplateState, opts?: CustomResourceOptions): IndexTemplate
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
body: Optional[str] = None,
index_template_id: Optional[str] = None,
name: Optional[str] = None) -> IndexTemplate
func GetIndexTemplate(ctx *Context, name string, id IDInput, state *IndexTemplateState, opts ...ResourceOption) (*IndexTemplate, error)
public static IndexTemplate Get(string name, Input<string> id, IndexTemplateState? state, CustomResourceOptions? opts = null)
public static IndexTemplate get(String name, Output<String> id, IndexTemplateState state, CustomResourceOptions options)
resources: _: type: opensearch:IndexTemplate 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.
- Body string
- The JSON body of the index template.
- Index
Template stringId - The ID of this resource.
- Name string
- The name of the index template.
- Body string
- The JSON body of the index template.
- Index
Template stringId - The ID of this resource.
- Name string
- The name of the index template.
- body String
- The JSON body of the index template.
- index
Template StringId - The ID of this resource.
- name String
- The name of the index template.
- body string
- The JSON body of the index template.
- index
Template stringId - The ID of this resource.
- name string
- The name of the index template.
- body str
- The JSON body of the index template.
- index_
template_ strid - The ID of this resource.
- name str
- The name of the index template.
- body String
- The JSON body of the index template.
- index
Template StringId - The ID of this resource.
- name String
- The name of the index template.
Import
$ pulumi import opensearch:index/indexTemplate:IndexTemplate template_1 template_1
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.