【发布时间】:2021-06-01 14:18:15
【问题描述】:
我正在使用 terraform template_file 数据资源创建一个文件,当我应用堆栈时,该文件应写入动态创建的 EC2 实例。换句话说,我希望在新创建的 EC2 实例的主文件夹中创建此文件。但是,此文件包含大括号语法 ${},terraform 正在尝试对其进行插值。我怎样才能避开这些大括号?
作为背景,我使用cloud-config 语法来编写这些文件。
例如:
${username} 应该写入文件,不在 terraform 中插值。
即使我使用双美元符号$$,terraform 仍然失败,因为它找不到变量:
... failed to render : <template_file>:105,18-26: Unknown variable; There is no variable named "username".
【问题讨论】:
-
您能否在问题中包含几行模板文件脚本?谢谢
-
使用不带大括号的 $username
标签: terraform