Terraform Configuring Vault - Certificate importing string literal issue

173 views
Skip to first unread message

walker.h...@gmail.com

unread,
Apr 18, 2018, 12:34:43 PM4/18/18
to Terraform
Ive what should be a simple json literal issue. IM curious how others handle using TF to populate vault and what im missing functionally. Clearly it works in the CLI so its a syntax/command understanding issue on my part. 


any advice or expertise is appreciated, thank you. 



############################# the .tf #############################
resource "vault_generic_secret" "Cert-pem" {
path = "CertStore/Cert-pem"
depends_on = ["vault_mount.CertStore-MOUNT"]
data_json = <<EOT
{
"value":          "${data.template_file.Cert-pem.rendered }"
}
EOT
}
data "template_file" "cert-pem" {
template = "${file("certs/Cert-pem")}"
}
############################# the .tf #############################





############################# the Errror #############################
Error: Error running plan: 1 error(s) occurred:

* vault_generic_secret.Cert-pem: invalid character '\r' in string literal
############################# the Errror #############################




############################# the  Successful CLI  #############################
[ ~]$ vault write CertStore/cert-pem \ value="-----BEGIN RSA PRIVATE KEY-----
> MIIEpAIBAAKCAQEA33DbTbVLvdRyQ4gzOKgP3xmHdLJZQFkhjMR5PhrSAz1frMOD9DLOrgSWoXAz


........


> RNXoOsNzZy36GNc2SJR5yo30WLA1fT2RHTK9Ev9w0QP8pHmXTLhWipbzCYumKQn4CIUunA==
> -----END RSA PRIVATE KEY-----"
Success! Data written to: CertStore/cert-pem
############################# the  Successful CLI  #############################







walker.h...@gmail.com

unread,
Apr 18, 2018, 1:05:42 PM4/18/18
to Terraform
nevermind, figured it out.. its the base64encode option

data "template_file" "cert-pem" {
template = "${base64encode("certs/Cert-pem")}"
}

it was simple.. cheers. 
Reply all
Reply to author
Forward
0 new messages