Terraform | Retrieve the (client-key) certificate from Cloud SQL

大城市里の小女人 提交于 2019-12-13 08:29:51

问题


I would like to retrieve the client-key SSL key of cloudsql via Terraform, I was able to retrieve the server-ca and the client-cert via terraform but have no idea how to get the client-key file. TO retrieve the client-cert I have used the below mentioned point: Please look.

resource "google_sql_ssl_cert" "client_cert" {
 depends_on  = ["google_sql_database_instance.new_instance_sql_master", 
            "google_sql_user.users"]
 common_name = "terraform1"
 project    = "${var.project_id}"
 instance ="${google_sql_database_instance.new_instance_sql_master.name}"
 }

Output.tf

output "client_cert" {
 value       = "${google_sql_ssl_cert.client_cert.0.cert}"
 description = "The CA Certificate used to connect to the SQL Instance via 
                SSL"
 }

Please let me know how can I retrieve the client-key private key. i.e server-ca, client-cert and I need client-key via terraform.


回答1:


In order to get the client private key, use the following snippet with any other parameters you wish to have:

output "client_privkey" {
  value       = "${google_sql_ssl_cert.client_cert.*.private_key}"
}

For client-certificate: value = "${google_sql_ssl_cert.client_cert.*.cert}"

For server certificate: value = ${google_sql_ssl_cert.client_cert.*.server_ca_cert}"



来源:https://stackoverflow.com/questions/55552300/terraform-retrieve-the-client-key-certificate-from-cloud-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!