将字符串附加到 Terraform 中列表的每个元素 [英] Append string to each element of a list in Terraform
本文介绍了将字符串附加到 Terraform 中列表的每个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的想法是通过在每个元素上附加一个字符串来修改列表的元素.这怎么可能实现?我没有找到任何允许我这样做的功能.
My idea is to have elements of a list modified by appending to each of them a string. How could this be achieved? I haven't find any function that allow me to do that.
推荐答案
你试过了吗formatlist()?
例如:
my_list_var = ["a", "b", "c"]
my_new_list = formatlist("%s-foo", var.mylist)
my_new_list 将是:
my_new_list will be:
["a-foo", "b-foo", "c-foo"]
你也可以传递另一个相同长度的列表作为参数来为每个元素附加不同的字符串.
Yo can also pass another list of the same length as parameter to append different strings to each element.
这篇关于将字符串附加到 Terraform 中列表的每个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文