Sab*_*Boz 8 set terraform terraform-template-file
我正在尝试创建一个集合,用作 terraform 中 setproduct 函数的参数。当我尝试时:
toset([a,b,c])
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息,提示我无法将元组转换为列表。我尝试过各种方法,例如在不同的地方使用tolist
and...
并只使用一对大()
括号,但我仍然无法使其工作 - 有人知道我如何从 a、b 和 c 创建一组吗?
Mar*_*cin 13
set
必须具有相同类型的元素。因此它可以是:
# set of strings
toset(["a", "b", "c"])
# set of numbers
toset([1, 2, 3])
# set of lists
toset([["b"], ["c", 4], [3,3]])
Run Code Online (Sandbox Code Playgroud)
您不能混合类型,因此您收到的错误是因为您正在混合类型,例如列表和数字
# will not work because different types
toset([["b"], ["c", 4], 3])
Run Code Online (Sandbox Code Playgroud)