Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Error Creating Elasticsearch Index with Date in Name via Terraform Provider Due to Unsupported Special Characters #882

Open
01martinelli opened this issue Oct 28, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@01martinelli
Copy link

Description
When trying to create an index with a date in the name via the Terraform Provider for Elastic, the operation fails due to unsupported special characters in the index name. The same command works in Kibana DevTools but not through the Terraform provider.

To Reproduce
Steps to reproduce the behavior:

  1. Terraform (TF) configuration used:
    resource "elasticstack_elasticsearch_index" "nginx-k8s-prod-logs-vcae" {
      name = " %3Cnginx-k8s-prod-logs-vcae-%7Bnow%2Fs%7Byyyy-MM-dd%7D%7D-00001%3E"
      aliases = {
        "nginx-k8s-prod-logs-vcae" = {
          is_write_index = true
        }
      }
    }
  2. Execute the following TF operations to replicate the error:
    • terraform plan
    • terraform apply
  3. Observe the following error in the output:
    ╷
    │ Error: invalid value for name (must contain lowercase alphanumeric characters and selected punctuation, see: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#indices-create-api-path-params)
    │
    │ with elasticstack_elasticsearch_index.nginx-k8s-prod-logs-vcae,
    │ on rollover-index_vcae.tf line 2, in resource "elasticstack_elasticsearch_index" "nginx-k8s-prod-logs-vcae":
    │ 2: name = "nginx-k8s-prod-logs-vcae-{now/s{yyyy-MM-dd}}-00001"
    │
    

Expected behavior
The index should be created successfully with the specified date in the name, similar to how the command works when executed directly in Kibana DevTools.

@01martinelli 01martinelli added the bug Something isn't working label Oct 28, 2024
@tobio
Copy link
Member

tobio commented Oct 29, 2024

This is an interesting issue with the provider. As it's written, supporting this behaviour doesn't really make sense since {now/s{yyyy-MM-dd}} would evaluate to something different if the TF module was applied on different days. The provider needs to track the initial index, not just a random one matching the pattern.

Fixing this issue in isolation will then mean users hit #94. There's a larger body of work required here to properly support lifecycle policy managed groups of indices within the provider. On the surface there's likely diminishing value in adding that support over say using data streams instead (I may certainly be missing some common cases there though).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants