Terraform错误从TF 0.11升级到0.12后计数参数无效

Terraform错误从TF 0.11升级到0.12后计数参数无效,terraform,terraform0.12+,Terraform,Terraform0.12+,在从0.11升级到0.12之后,由于依赖关系,在开始之前可以工作的东西失败了: Error: Invalid count argument on ../modules/app-web/fargate.tf line 289, in resource "aws_security_group_rule" "proxy2target_group_1": 289: count = var.allow_security

在从0.11升级到0.12之后,由于依赖关系,在开始之前可以工作的东西失败了:

Error: Invalid count argument
  on ../modules/app-web/fargate.tf line 289, in resource "aws_security_group_rule" "proxy2target_group_1":
 289:   count                    = var.allow_security_group_id == "" ? 0 : 1
The "count" value depends on resource attributes that cannot be determined
until apply, so Terraform cannot predict how many instances will be created.
To work around this, use the -target argument to first apply only the
resources that the count depends on.
这确实取决于另一个资源:
allow\u security\u group\u id=module.repl ssm tunnel proxy。此\u security\u group\u id
但真的是找到所有这些资源并使用-target多次运行TF的唯一解决方案吗?为什么它以前能工作?我能在没有多次TF运行的情况下让它工作吗

更新:我已经尝试了建议的解决方案,运行
terraform apply-target=aws\u codepippeline.codepippeline\u prod-target=aws\u codepippeline.codepippeline\u stage\u from\u ecr-target=module.repl-ssm-tunnel-proxy-target=module.direct connect.aws\u route\u tables.private
,未失败,但也未应用任何内容。可能是因为所有这些都在模块内部(即production.tf->modules/myapp->modules/helper XY),并且由于我没有针对顶级模块(myapp),所以没有应用任何内容?
当然,如果我尝试添加顶级模块,它会再次失败,因为最初的计数问题:
terraformapply-target=module.direct-connect.aws_route_tables.private-目标模块.direct_-connect
Catch 22?:-(

从0.12升级到0.13删除了许多警告,其余的警告很容易通过更改代码来修复。

您可以编辑您的问题,使其包含导致此错误的警告吗?Terraform 0.11中也存在此约束,但它有不同的错误消息,不太详细,并且不包含建议使用
-target
。如果您在Terraform 0.11上没有看到它,那么我猜您的Terraform 0.11配置会随着时间的推移逐渐演变,当您将
计数
添加到此资源时,依赖项已经创建,因此ID值已经已知。只有当计划包含UDE为其他资源执行了“创建”操作,这就是为什么
-target
选项可以绕过它。您在此处共享的信息有限,很难深入了解细节,但总体思路是确定
输出的依赖关系子图中有哪些资源“这是您模块中的\u security\u group\u id
-target
的组合。我不能说您在问题中列出的是否正确,因为我不熟悉您配置中的依赖关系。