0

I have a running vault server, I enabled transit secret engine and created a vault transit secret backend_key through terraform.

resource "vault_mount" "transit" {
  path = "transit"
  type = "transit"
}


resource "vault_transit_secret_backend_key" "transit_key" {
  backend = vault_mount.transit.path
  name    = "test-pagination-key"
  type    = "chacha20-poly1305"
}

I am able to see the generated backend key in vault UI enter image description here

Post the creation of this key, I need to go inside key actions and select datakey and select plaintext key and hit "create datakey" to fetch the backend key in plain text format.

enter image description here

enter image description here

But i couldn't find any terraform block to fetch this information using terraform, I have to manually fetch the datakey in plaintext format.

How can I get that key through terraform??

There is an API call I can see from vault documentation, Document

sample request
curl \
    --header "X-Vault-Token: ..." \
    --request POST \
    --data @payload.json \
    http://127.0.0.1:8200/v1/transit/datakey/plaintext/my-key

sample response
{
  "data": {
    "plaintext": "dGhlIHF1aWNrIGJyb3duIGZveAo=",
    "ciphertext": "vault:v1:abcdefgh"
  }
}

How can I make this API call using terraform??

Kindly gimme some path to proceed forward in this issue

Marko E
  • 13,362
  • 2
  • 19
  • 28
Bala krishna
  • 519
  • 1
  • 10
  • 24

0 Answers0