title: Making a user or role with elasticsearch-py in AWS
body: <p>I'm trying to create users and roles via the elasticsearch python client documented here: <a href="https://elasticsearch-py.readthedocs.io/en/v7.14.1/" rel="nofollow noreferrer">https://elasticsearch-py.readthedocs.io/en/v7.14.1/</a>. If I use HTTP requests alone and if I ignore the certificates, I can reach the application and make requests with the payloads suggested in <a href="https://opendistro.github.io/for-elasticsearch-docs/docs/security/access-control/api/" rel="nofollow noreferrer">https://opendistro.github.io/for-elasticsearch-docs/docs/security/access-control/api/</a>. However I'm trying to use a secure connection to get to elasticsearch in AWS. According to their documentation in <a href="https://docs.aws.amazon.com/opensearch-service/latest/developerguide/request-signing.html#request-signing-python" rel="nofollow noreferrer">https://docs.aws.amazon.com/opensearch-service/latest/developerguide/request-signing.html#request-signing-python</a>, I should be using the elastic search client like this:</p>
  <pre><code>region = 'my-region-1'
  service = 'opensearchservice'
  credentials = boto3.Session().get_credentials()
  awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, region, service,
                     session_token=credentials.token)
  
  elasticsearch = Elasticsearch(
      hosts=[{'host': self._host, 'port': 443}],
      http_auth=awsauth,
      use_ssl=True,
      verify_certs=True,
      connection_class=RequestsHttpConnection
  )
  </code></pre>
  <p>I'm using boto3 to create the session and AWS4Auth to try and get the secure connection. However, I can't find anywhere how to actually send a plain payload to elastic search endpoints. For example, for this endpoint:</p>
  <pre><code>curl -X PUT http://localhost:443/_opendistro/_security/api/roles/jesperancinha-role -d &quot;{}&quot; (...)
  </code></pre>
  <p>It seems like that we need to send an index and that's not what I'm looking for. I just want to create a user with a payload like this one:</p>
  <pre><code>{
      &quot;cluster_permissions&quot; : [
        &quot;indices_monitor&quot;,
      ],
      &quot;index_permissions&quot; : [
        {
          &quot;index_patterns&quot; : [
            &quot;*&quot;
          ],
          &quot;dls&quot; : &quot;&quot;,
          &quot;fls&quot; : [ ],
          &quot;masked_fields&quot; : [ ],
          &quot;allowed_actions&quot; : [
            &quot;read&quot;,
            &quot;indices:monitor/stats&quot;
          ]
        }
      ],
      &quot;tenant_permissions&quot; : [
        {
          &quot;tenant_patterns&quot; : [
            &quot;human_resources&quot;
          ],
          &quot;allowed_actions&quot; : [
            &quot;kibana_all_read&quot;
          ]
        }
      ]
  }
  </code></pre>
  <p>It would be great if this could be done via the elasticsearch-py client, but if you have any other idea, please let me know. Thanks!</p>