问题描述
我要升级到 terraform 12 并且有一个引用根存储库的 asg 模块。作为其中的一部分,它使用 data.template_file 资源将用户数据附加到 asg,然后将其放入实例上的日志文件中。模块如下所示;
module "cef_fleet" {
source = "git::ssh://[email protected]/asg-repo.git?ref=terraform12"
user_data_rendered = data.template_file.init.rendered
instance_type = var.instance_type
ami = var.ami
etc ...
正如你所见,它调用了数据资源;
data "template_file" "init" {
count = signum(var.cluster_size_max)
template = file("${path.module}/template-files/init.sh")
vars = {
account_name = var.account_name
aws_account_number = var.aws_account_number
这在 terraform 11 中工作正常,但是当我更改为 terraoform 12 并尝试应用时,我收到此错误:
*Because data.template_file.init has "count" set,its attributes must be
accessed on specific instances.
For example,to correlate with indices of a referring resource,use:
data.template_file.init[count.index]*
如果我在模块中将其更改为 user_data_rendered = data.template_file.init[count.index] 然后我收到此错误;
The "count" object can be used only in "resource" and "data" blocks,and only
when the "count" argument is set.
我不知道在这里做什么。如果我将 .rendered 留在里面,那么它似乎无法识别 [count.index],因为我再次遇到第一个错误。有人对我需要做什么有任何建议吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)