跳至主要内容

issensitive 函数

issensitive 接收任何值,如果该值被标记为敏感,则返回 true,否则返回 false

如果您需要以编程方式确定值是否敏感,例如,如果您有一个包含敏感和非敏感值的值,并且您需要将这两部分分开,则 issensitive 函数可能很有用。

代码块
variable "environment_variables" {
description = "A list of environment variables that may contain both sensitive and non-sensitive values"
type = map(string)
sensitive = true
}

locals {
sensitive_variables = [for key, value in var.environment_variables: key if issensitive(value)]
nonsensitive_variables = [for key, value in var.environment_variables: key if !issensitive(value)]
}

示例

代码块
> issensitive(1)
false
> issensitive("hello")
false
> issensitive(sensitive("hello"))
true