orange-cloudfoundry / terraform-provider-credhub

This terraform provider let you create and retrieve credentials from credhub
Apache License 2.0
8 stars 2 forks source link

credhub provider unable to retrieve secret from credhub server #19

Closed balloray closed 1 year ago

balloray commented 1 year ago

Trying to use terraform credhub provider. I have below for my provider.tf

terraform {
  required_providers {
    credhub = {
      source = "orange-cloudfoundry/credhub"
      version = "0.15.6"
    }
  }
}

provider "credhub" {
  credhub_server      = "https://example.com/"
  username            = ""
  password            = ""
  skip_ssl_validation = true
  client_id           = xxxxx
  client_secret       = xxxxxx
  ca_cert             = ""
}

next is my main.tf

data "credhub_password" "my_data" {
  name = "/concourse/sbx/password"
  // or you can use credential id:
  // cred_id = "mydata-id"
}

resource "kubernetes_secret" "example" {
  metadata {
    name = "basic-auth"
  }

  data = {
    username = "admin"
    password = data.credhub_password.my_data.name
  }
}

When I look up the secret created the data for password is blank. Terraform is not able to pick up the password I have set in the credhub server. Infact the key for passowrd is not in the secret at all

balloray commented 1 year ago

Got this sorted out with below.

resource "kubernetes_secret" "example" {
  metadata {
    name = "basic-auth"
  }

  data = {
    username = "admin"
    password = data.credhub_password.my_data.password
  }
}