title: How to write roles and policies in Hashicorp Vault using a pipeline
body: <p>I am using Hashicorp Vault for managing and storing my secrets. And using Gitlab as a CI/CD pipeline to read those secrets. Using this documentation <a href="https://docs.gitlab.com/ee/ci/examples/authenticating-with-hashicorp-vault/" rel="nofollow noreferrer">https://docs.gitlab.com/ee/ci/examples/authenticating-with-hashicorp-vault/</a>,  I am able to read the secrets using JWT.
  But those secrets/roles/policies I had already configured from Vault CLI</p>
  <p>What i want to know is if there is a way to create policies and roles using directly from the pipeline. For example 1st step is to create the role like this -</p>
  <pre><code>$ vault write auth/jwt/role/myproject-production - &lt;&lt;EOF
  {
    &quot;role_type&quot;: &quot;jwt&quot;,
    &quot;policies&quot;: [&quot;myproject-production&quot;],
    &quot;token_explicit_max_ttl&quot;: 60,
    &quot;user_claim&quot;: &quot;user_email&quot;,
    &quot;bound_claims_type&quot;: &quot;glob&quot;,
    &quot;bound_claims&quot;: {
      &quot;project_id&quot;: &quot;42&quot;,
      &quot;ref_protected&quot;: &quot;true&quot;,
      &quot;ref_type&quot;: &quot;tag&quot;,
      &quot;ref&quot;: &quot;auto-deploy-*&quot;
    }
  }
  EOF
  </code></pre>
  <p>Here you can see I have attached a policy <code>myproject-production</code> to this role which will be created like this -</p>
  <pre><code>$ vault policy write myproject-production - &lt;&lt;EOF
  # Policy name: myproject-production
  #
  # Read-only permission on 'secret/data/myproject/production/*' path
  path &quot;secret/data/myproject/production/*&quot; {
    capabilities = [ &quot;read&quot; ]
  }
  EOF
  </code></pre>
  <p>How do i perform these 2 steps from a pipeline after Authentication happens successfully from Vault.?
  Right now what i am doing is when a new user comes in, I go and create <code>policy</code> and <code>roles</code> for him and the same the user uses in the pipeline to read the secrets.</p>