opensearch.ComponentTemplate
Explore with Pulumi AI
Component templates are building blocks for constructing index templates that specify index mappings, settings, and aliases. You cannot directly apply a component template to a data stream or index. To be applied, a component template must be included in an index template’s composed_of
list.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as opensearch from "@pulumi/opensearch";
const test = new opensearch.ComponentTemplate("test", {body: `{
"template": {
"settings": {
"index": {
"number_of_shards": "1"
}
},
"mappings": {
"properties": {
"host_name": {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
}
}
},
"aliases": {
"mydata": { }
}
}
}
`});
import pulumi
import pulumi_opensearch as opensearch
test = opensearch.ComponentTemplate("test", body="""{
"template": {
"settings": {
"index": {
"number_of_shards": "1"
}
},
"mappings": {
"properties": {
"host_name": {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
}
}
},
"aliases": {
"mydata": { }
}
}
}
""")
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 {
_, err := opensearch.NewComponentTemplate(ctx, "test", &opensearch.ComponentTemplateArgs{
Body: pulumi.String(`{
"template": {
"settings": {
"index": {
"number_of_shards": "1"
}
},
"mappings": {
"properties": {
"host_name": {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
}
}
},
"aliases": {
"mydata": { }
}
}
}
`),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Opensearch = Pulumi.Opensearch;
return await Deployment.RunAsync(() =>
{
var test = new Opensearch.ComponentTemplate("test", new()
{
Body = @"{
""template"": {
""settings"": {
""index"": {
""number_of_shards"": ""1""
}
},
""mappings"": {
""properties"": {
""host_name"": {
""type"": ""keyword""
},
""created_at"": {
""type"": ""date"",
""format"": ""EEE MMM dd HH:mm:ss Z yyyy""
}
}
},
""aliases"": {
""mydata"": { }
}
}
}
",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.opensearch.ComponentTemplate;
import com.pulumi.opensearch.ComponentTemplateArgs;
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 test = new ComponentTemplate("test", ComponentTemplateArgs.builder()
.body("""
{
"template": {
"settings": {
"index": {
"number_of_shards": "1"
}
},
"mappings": {
"properties": {
"host_name": {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
}
}
},
"aliases": {
"mydata": { }
}
}
}
""")
.build());
}
}
resources:
test:
type: opensearch:ComponentTemplate
properties:
body: |+
{
"template": {
"settings": {
"index": {
"number_of_shards": "1"
}
},
"mappings": {
"properties": {
"host_name": {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
}
}
},
"aliases": {
"mydata": { }
}
}
}
Create ComponentTemplate Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ComponentTemplate(name: string, args: ComponentTemplateArgs, opts?: CustomResourceOptions);
@overload
def ComponentTemplate(resource_name: str,
args: ComponentTemplateArgs,
opts: Optional[ResourceOptions] = None)
@overload
def ComponentTemplate(resource_name: str,
opts: Optional[ResourceOptions] = None,
body: Optional[str] = None,
component_template_id: Optional[str] = None,
name: Optional[str] = None)
func NewComponentTemplate(ctx *Context, name string, args ComponentTemplateArgs, opts ...ResourceOption) (*ComponentTemplate, error)
public ComponentTemplate(string name, ComponentTemplateArgs args, CustomResourceOptions? opts = null)
public ComponentTemplate(String name, ComponentTemplateArgs args)
public ComponentTemplate(String name, ComponentTemplateArgs args, CustomResourceOptions options)
type: opensearch:ComponentTemplate
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 ComponentTemplateArgs
- 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 ComponentTemplateArgs
- 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 ComponentTemplateArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ComponentTemplateArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ComponentTemplateArgs
- 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 componentTemplateResource = new Opensearch.ComponentTemplate("componentTemplateResource", new()
{
Body = "string",
ComponentTemplateId = "string",
Name = "string",
});
example, err := opensearch.NewComponentTemplate(ctx, "componentTemplateResource", &opensearch.ComponentTemplateArgs{
Body: pulumi.String("string"),
ComponentTemplateId: pulumi.String("string"),
Name: pulumi.String("string"),
})
var componentTemplateResource = new ComponentTemplate("componentTemplateResource", ComponentTemplateArgs.builder()
.body("string")
.componentTemplateId("string")
.name("string")
.build());
component_template_resource = opensearch.ComponentTemplate("componentTemplateResource",
body="string",
component_template_id="string",
name="string")
const componentTemplateResource = new opensearch.ComponentTemplate("componentTemplateResource", {
body: "string",
componentTemplateId: "string",
name: "string",
});
type: opensearch:ComponentTemplate
properties:
body: string
componentTemplateId: string
name: string
ComponentTemplate 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 ComponentTemplate resource accepts the following input properties:
- Body string
- The JSON body of the template.
- Component
Template stringId - The ID of this resource.
- Name string
- Name of the component template to create.
- Body string
- The JSON body of the template.
- Component
Template stringId - The ID of this resource.
- Name string
- Name of the component template to create.
- body String
- The JSON body of the template.
- component
Template StringId - The ID of this resource.
- name String
- Name of the component template to create.
- body string
- The JSON body of the template.
- component
Template stringId - The ID of this resource.
- name string
- Name of the component template to create.
- body str
- The JSON body of the template.
- component_
template_ strid - The ID of this resource.
- name str
- Name of the component template to create.
- body String
- The JSON body of the template.
- component
Template StringId - The ID of this resource.
- name String
- Name of the component template to create.
Outputs
All input properties are implicitly available as output properties. Additionally, the ComponentTemplate 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 ComponentTemplate Resource
Get an existing ComponentTemplate 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?: ComponentTemplateState, opts?: CustomResourceOptions): ComponentTemplate
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
body: Optional[str] = None,
component_template_id: Optional[str] = None,
name: Optional[str] = None) -> ComponentTemplate
func GetComponentTemplate(ctx *Context, name string, id IDInput, state *ComponentTemplateState, opts ...ResourceOption) (*ComponentTemplate, error)
public static ComponentTemplate Get(string name, Input<string> id, ComponentTemplateState? state, CustomResourceOptions? opts = null)
public static ComponentTemplate get(String name, Output<String> id, ComponentTemplateState state, CustomResourceOptions options)
resources: _: type: opensearch:ComponentTemplate 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 template.
- Component
Template stringId - The ID of this resource.
- Name string
- Name of the component template to create.
- Body string
- The JSON body of the template.
- Component
Template stringId - The ID of this resource.
- Name string
- Name of the component template to create.
- body String
- The JSON body of the template.
- component
Template StringId - The ID of this resource.
- name String
- Name of the component template to create.
- body string
- The JSON body of the template.
- component
Template stringId - The ID of this resource.
- name string
- Name of the component template to create.
- body str
- The JSON body of the template.
- component_
template_ strid - The ID of this resource.
- name str
- Name of the component template to create.
- body String
- The JSON body of the template.
- component
Template StringId - The ID of this resource.
- name String
- Name of the component template to create.
Import
Import by name
$ pulumi import opensearch:index/componentTemplate:ComponentTemplate test terraform-test
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.