Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/data-sources/elasticsearch_index_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ output "template" {
- `composed_of` (List of String) An ordered list of component template names.
- `data_stream` (List of Object) If this object is included, the template is used to create data streams and their backing indices. Supports an empty object. (see [below for nested schema](#nestedatt--data_stream))
- `id` (String) Internal identifier of the resource
- `ignore_missing_component_templates` (List of String) A list of component template names that are ignored if missing.
- `index_patterns` (Set of String) Array of wildcard (*) expressions used to match the names of data streams and indices during creation.
- `metadata` (String) Optional user metadata about the index template.
- `priority` (Number) Priority to determine index template precedence when a new data stream or index is created.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/elasticsearch_index_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ resource "elasticstack_elasticsearch_index_template" "my_data_stream" {
- `composed_of` (List of String) An ordered list of component template names.
- `data_stream` (Block List, Max: 1) If this object is included, the template is used to create data streams and their backing indices. Supports an empty object. (see [below for nested schema](#nestedblock--data_stream))
- `elasticsearch_connection` (Block List, Max: 1, Deprecated) Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead. (see [below for nested schema](#nestedblock--elasticsearch_connection))
- `ignore_missing_component_templates` (List of String) A list of component template names that are ignored if missing.
- `metadata` (String) Optional user metadata about the index template.
- `priority` (Number) Priority to determine index template precedence when a new data stream or index is created.
- `template` (Block List, Max: 1) Template to be applied. It may optionally include an aliases, mappings, lifecycle, or settings configuration. (see [below for nested schema](#nestedblock--template))
Expand Down
20 changes: 20 additions & 0 deletions internal/elasticsearch/index/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ func ResourceTemplate() *schema.Resource {
Type: schema.TypeString,
},
},
"ignore_missing_component_templates": {
Description: "A list of component template names that are ignored if missing.",
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"data_stream": {
Description: "If this object is included, the template is used to create data streams and their backing indices. Supports an empty object.",
Type: schema.TypeList,
Expand Down Expand Up @@ -221,6 +230,14 @@ func resourceIndexTemplatePut(ctx context.Context, d *schema.ResourceData, meta
}
indexTemplate.ComposedOf = compsOf

compsOfIgnore := make([]string, 0)
if v, ok := d.GetOk("ignore_missing_component_templates"); ok {
for _, c := range v.([]interface{}) {
compsOfIgnore = append(compsOfIgnore, c.(string))
}
}
indexTemplate.IgnoreMissingComponentTemplates = compsOfIgnore

if v, ok := d.GetOk("data_stream"); ok {
// 8.x workaround
hasAllowCustomRouting := false
Expand Down Expand Up @@ -371,6 +388,9 @@ func resourceIndexTemplateRead(ctx context.Context, d *schema.ResourceData, meta
if err := d.Set("composed_of", tpl.IndexTemplate.ComposedOf); err != nil {
return diag.FromErr(err)
}
if err := d.Set("ignore_missing_component_templates", tpl.IndexTemplate.IgnoreMissingComponentTemplates); err != nil {
return diag.FromErr(err)
}
if stream := tpl.IndexTemplate.DataStream; stream != nil {
ds := make([]interface{}, 1)
dSettings := make(map[string]interface{})
Expand Down
8 changes: 8 additions & 0 deletions internal/elasticsearch/index/template_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ func DataSourceTemplate() *schema.Resource {
Type: schema.TypeString,
},
},
"ignore_missing_component_templates": {
Description: "A list of component template names that are ignored if missing.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"data_stream": {
Description: "If this object is included, the template is used to create data streams and their backing indices. Supports an empty object.",
Type: schema.TypeList,
Expand Down
21 changes: 11 additions & 10 deletions internal/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,17 @@ type Application struct {
}

type IndexTemplate struct {
Name string `json:"-"`
Create bool `json:"-"`
Timeout string `json:"-"`
ComposedOf []string `json:"composed_of"`
DataStream *DataStreamSettings `json:"data_stream,omitempty"`
IndexPatterns []string `json:"index_patterns"`
Meta map[string]interface{} `json:"_meta,omitempty"`
Priority *int `json:"priority,omitempty"`
Template *Template `json:"template,omitempty"`
Version *int `json:"version,omitempty"`
Name string `json:"-"`
Create bool `json:"-"`
Timeout string `json:"-"`
ComposedOf []string `json:"composed_of"`
IgnoreMissingComponentTemplates []string `json:"ignore_missing_component_templates"`
DataStream *DataStreamSettings `json:"data_stream,omitempty"`
IndexPatterns []string `json:"index_patterns"`
Meta map[string]interface{} `json:"_meta,omitempty"`
Priority *int `json:"priority,omitempty"`
Template *Template `json:"template,omitempty"`
Version *int `json:"version,omitempty"`
}

type DataStreamSettings struct {
Expand Down