尽管声明了Terraform仍未显示输出

时间:2020-01-22 10:25:54

标签: terraform

我在output.tf文件的TF模块中声明以下输出:

output "jenkins_username" {
  value       = "${local.jenkins_username}"
  description = "Jenkins admin username"
  #sensitive   = true
}


output "jenkins_password" {
  value       = "${local.jenkins_password}"
  description = "Jenkins admin password"
  #sensitive   = true
}

已在main.tf中声明了相应的本地语言,如下所示:

locals {
  jenkins_username = "${var.jenkins_username == "" ? random_string.j_username.result : var.jenkins_username}"
  jenkins_password = "${var.jenkins_password == "" ? random_string.j_password.result : var.jenkins_password}"
}

但是,apply完成后,我看不到任何相关输出,而且,即使我调用显式output命令,也不会显示该输出:

$ terraform output jenkins_password

The output variable requested could not be found in the state
file. If you recently added this to your configuration, be
sure to run `terraform apply`, since the state won't be updated
with new output variables until that command is run.

1 个答案:

答案 0 :(得分:0)

我遇到了完全相同的问题。对我有用的是在第一次部署中注释掉输出变量,并在成功后取消注释。