Terraform kubernetes secret with .p12 file

459 Views Asked by At

I have to create a secret using .p12 keystore (binary file). If I am creating it as below-

resource "kubernetes_secret_v1" "app_keystore" {
  metadata {
    name = "app-keystore"
    namespace = "test"
  }
  type = "Opaque"
  data = {
   "test.p12"=file("./secret/appkeystore/test.p12")
  }
}

It is giving below error

enter image description here

With filebase64 encoding, no error but the .p12 is encoded twice.

1

There are 1 best solutions below

0
On

Found the resolution.

binary_data = {
    "test.p12"=filebase64("./secret/appkeystore/test.p12")
  }

The correct encoding for a binary file is filebase64.