目标:我想打印出 的敏感值foo_resource.name.sensitive_field
。
最初我尝试创建一个输出:
\noutput "password" {\n value = foo_resource.name.sensitive_field\n}\n
Run Code Online (Sandbox Code Playgroud)\n我得到了
\n Error: Output refers to sensitive values\n\xe2\x94\x82 \n\xe2\x94\x82 on main.tf line 186:\n\xe2\x94\x82 186: output "password" {\n\xe2\x94\x82 \n\xe2\x94\x82 To reduce the risk of accidentally exporting sensitive data that was intended to be only internal, Terraform requires that any root module output containing sensitive data be\n\xe2\x94\x82 explicitly marked as sensitive, to confirm your intent.\n\xe2\x94\x82 \n\xe2\x94\x82 If you do intend to export this data, annotate the output value as sensitive by adding the following argument:\n\xe2\x94\x82 sensitive = true\n\xe2\x95\xb5\n
Run Code Online (Sandbox Code Playgroud)\n所以我添加sensitive = true
了:
output "password" {\n value = foo_resource.name.sensitive_field\n sensitive = true\n}\n
Run Code Online (Sandbox Code Playgroud)\n然后当我再次运行它时,我得到:
\n$ terraform output\npassword = <sensitive>\n
Run Code Online (Sandbox Code Playgroud)\n
terraform output -raw password
Run Code Online (Sandbox Code Playgroud)
就可以了。
有关更多详细信息,请参阅文档:
Note: When using the -json or -raw command-line flag, any sensitive values in Terraform state will be displayed in plain text. For more information, see Sensitive Data in State.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9996 次 |
最近记录: |