如何解决terraform将输出保存到文件
我正在使用terraform证书。寻找有关如何使用terrafrom将pem和cert值转储到磁盘文件的信息。这是输出变量。我想将它们转储到变量。任何参考代码段??
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。例如:
resource "local_file" "private_key" {
content = venafi_certificate.this.private_key_pem
filename = "private_key.pem"
}
,
这是一个老问题,但如果有人遇到同样的问题,让我把我的答案放在这里。 您可以将所有输出发送到这样的文件
terraform output > file.txt
其中 file.txt 是包含输出的文件