Skip to content

Commit 5f4f2a4

Browse files
committed
Fix: Only set description field when not empty to avoid Terraform validation errors
The description field was being set unconditionally in resourceRoleRead, which caused Terraform to reject the plan when the description was empty because it was trying to set a non-computed attribute to an empty string. This fix ensures that the description field is only set when it contains actual content, preventing the 'Provider produced invalid plan' error for elasticstack_kibana_security_role resources without descriptions. Fixes: elastic#1186
1 parent 9754e6a commit 5f4f2a4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/kibana/role.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,11 @@ func resourceRoleRead(ctx context.Context, d *schema.ResourceData, meta interfac
350350
if err := d.Set("kibana", flattenKibanaRoleKibanaData(&role.Kibana)); err != nil {
351351
return diag.FromErr(err)
352352
}
353-
if err := d.Set("description", role.Description); err != nil {
354-
return diag.FromErr(err)
353+
// Only set description if it's not empty to avoid Terraform validation errors
354+
if strings.TrimSpace(role.Description) != "" {
355+
if err := d.Set("description", role.Description); err != nil {
356+
return diag.FromErr(err)
357+
}
355358
}
356359
if role.Metadata != nil {
357360
metadata, err := json.Marshal(role.Metadata)

0 commit comments

Comments
 (0)