in internal/elasticsearch/index/ilm.go [22:115]
func ResourceIlm() *schema.Resource {
ilmSchema := map[string]*schema.Schema{
"id": {
Description: "Internal identifier of the resource",
Type: schema.TypeString,
Computed: true,
},
"name": {
Description: "Identifier for the policy.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"metadata": {
Description: "Optional user metadata about the ilm policy. Must be valid JSON document.",
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringIsJSON,
DiffSuppressFunc: utils.DiffJsonSuppress,
},
"hot": {
Description: "The index is actively being updated and queried.",
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
AtLeastOneOf: []string{"hot", "warm", "cold", "frozen", "delete"},
Elem: &schema.Resource{
Schema: getSchema("set_priority", "unfollow", "rollover", "readonly", "shrink", "forcemerge", "searchable_snapshot", "downsample"),
},
},
"warm": {
Description: "The index is no longer being updated but is still being queried.",
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
AtLeastOneOf: []string{"hot", "warm", "cold", "frozen", "delete"},
Elem: &schema.Resource{
Schema: getSchema("set_priority", "unfollow", "readonly", "allocate", "migrate", "shrink", "forcemerge", "downsample"),
},
},
"cold": {
Description: "The index is no longer being updated and is queried infrequently. The information still needs to be searchable, but it’s okay if those queries are slower.",
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
AtLeastOneOf: []string{"hot", "warm", "cold", "frozen", "delete"},
Elem: &schema.Resource{
Schema: getSchema("set_priority", "unfollow", "readonly", "searchable_snapshot", "allocate", "migrate", "freeze", "downsample"),
},
},
"frozen": {
Description: "The index is no longer being updated and is queried rarely. The information still needs to be searchable, but it’s okay if those queries are extremely slow.",
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
AtLeastOneOf: []string{"hot", "warm", "cold", "frozen", "delete"},
Elem: &schema.Resource{
Schema: getSchema("searchable_snapshot"),
},
},
"delete": {
Description: "The index is no longer needed and can safely be removed.",
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
AtLeastOneOf: []string{"hot", "warm", "cold", "frozen", "delete"},
Elem: &schema.Resource{
Schema: getSchema("wait_for_snapshot", "delete"),
},
},
"modified_date": {
Description: "The DateTime of the last modification.",
Type: schema.TypeString,
Computed: true,
},
}
utils.AddConnectionSchema(ilmSchema)
return &schema.Resource{
Description: "Creates or updates lifecycle policy. See: https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html and https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-index-lifecycle.html",
CreateContext: resourceIlmPut,
UpdateContext: resourceIlmPut,
ReadContext: resourceIlmRead,
DeleteContext: resourceIlmDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Schema: ilmSchema,
}
}