Skip to content

[Bug] Cannot create roles with spaces after update to 0.12.0 #1372

@rachitakumar

Description

@rachitakumar

Describe the bug
After upgrading the terraform provider version from 0.11.8 to 0.12.0, it seems there is now an issue with creating roles that contain spaces - it looks like it may be due to changes outlined here: #1280

To Reproduce
Steps to reproduce the behavior:

  1. TF configuration used '...'
terraform {
  required_providers {
    elasticstack = {
      source  = "elastic/elasticstack"
      version = "0.12.0"
    }
  }
}
provider "elasticstack" {
  elasticsearch {
    endpoints = ["endpoint"]
    api_key   = "apikey"
  }
}
resource "elasticstack_elasticsearch_security_role_mapping" "Engineering_Analyst" {
  name    = "Engineering Analyst" 
  enabled = true
  roles   = ["analyst"]
  rules   = jsonencode({
    field = {
      username = "*"
    }
  })
  metadata = jsonencode({
    _reserved = {
      spaces = ["engineering", "analytics"]
    }
  })
}
  1. TF operations to execute to get the error '...' [e.g terraform plan,terraform apply, terraform destroy]
  2. See the error in the output '...'

Expected behavior
When running terraform plan, the output shows this is not possible due to the space between engineering analyst:

➜  elasticstack-terraform terraform plan
╷
│ Error: Invalid Attribute Value Match
│
│   with elasticstack_elasticsearch_security_role_mapping.Engineering_Analyst,
│   on main.tf line 16, in resource "elasticstack_elasticsearch_security_role_mapping" "Engineering_Analyst":
│   16:   name    = "Engineering Analyst"
│
│ Attribute name must contain printable characters and no spaces, got: Engineering Analyst

Versions (please complete the following information):

  • OS: Mac, Linux
  • Terraform Version 1.13.4
  • Provider version 0.12.0
  • Elasticsearch Version (tested on these versions 8.19x and 9.1.5)

Additional context
There is a concern here that a regression being introduced where older versions of the provider work - and since 0.11.8 what the provider allows differs from what the elasticsearch api allows. In elasticsearch we are able to create roles using API with spaces and in the UI no problem, this issue is limited to using the terraform provider. As this is an elasticstack terraform provider, we would expect the functionality to be in sync.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions