本文介绍了terraform 将输出保存到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 terraform 生成证书.寻找有关如何使用 terrafrom 将 pem 和 cert 值转储到磁盘文件的信息.这是输出变量.我想将它们转储到变量中.任何参考代码片段??

I am using terraform to gnerate certificates. Looking for information on how to dump pem and cert values to disk file using terrafrom. here is the output variable. i want to dump them to variable. any reference code snippet ??

output "private_key" {
  description = "The venafi private key"
  value       = venafi_certificate.this.private_key_pem
}

output "certificate_body" {
  description = "The acm certificate body"
  value       = venafi_certificate.this.certificate
}

output "certificate_chain" {
  description = "The acm certificate chain"
  value       = venafi_certificate.this.chain
}
'''

推荐答案

一种方法是使用 local_file.例如:

One way would be to use local_file. For example:

resource "local_file" "private_key" {
    content  = venafi_certificate.this.private_key_pem
    filename = "private_key.pem"
}

这篇关于terraform 将输出保存到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 23:29