# Adding new user in role mapping

**URL:** <https://discuss.elastic.co/t/adding-new-user-in-role-mapping/339755>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [August 1, 2023, 7:06am UTC](https://discuss.elastic.co/t/adding-new-user-in-role-mapping/339755 "2023-08-01T07:06:30Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![sholzhauer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sholzhauer/32/110282_2.png) [@sholzhauer](https://discuss.elastic.co/u/sholzhauer)\
**Post date:** [August 1, 2023, 9:03am UTC](https://discuss.elastic.co/t/adding-new-user-in-role-mapping/339755/2 "2023-08-01T09:03:06Z")

</div>

Hi,

This is because the update of a role mapping does not "add" but "overwrites", you use the api to define how it should look, no matter of the current state.

I also responded to your [question about removing users](https://discuss.elastic.co/t/how-to-remove-a-user-from-role-mapping/339688/4); You can use the same approach here by first retrieving the current implementation and then updating it with the desired set.

Another approach you could take is to use [Terraform](https://registry.terraform.io/providers/elastic/elasticstack/latest/docs/resources/elasticsearch_security_role_mapping) if you are familiar, it can handle the logic for you.

---

_[View the full topic](https://discuss.elastic.co/t/adding-new-user-in-role-mapping/339755)._
