我在terraform 0.11.14上,我具有aws_cloudformation_stack资源,如下所示:
resource "aws_cloudformation_stack" "ingress_sg" {
name = "bastion-${var.accountName}-ingressIntuitIPs"
lifecycle {
prevent_destroy = true
}
parameters {
VpcId = "${var.default_vpc_id}"
Port = 22
Name = "bastion-${var.accountName}-ingressIntuitIPs"
GroupName = "true"
}
}```
when i run terraform, its throwing this error:
```Error: module.swimlane.module.bastion.aws_cloudformation_stack.ingress_sg: 1 error occurred:
* module.swimlane.module.bastion.aws_cloudformation_stack.ingress_sg: invalid variable syntax: "VpcId". Did you mean 'var.VpcId'? If this is part of inline `template` parameter
then you must escape the interpolation with two dollar signs. For
example: ${a} becomes $${a}.
感谢您的帮助。预先感谢。
答案 0 :(得分:0)
错误消息确切说明了您需要执行的操作:
"you must escape the interpolation with two dollar signs. For
example: ${a} becomes $${a}."
表示
VpcId = "${var.default_vpc_id}"
成为
VpcId = "$${var.default_vpc_id}"
答案 1 :(得分:0)
在模板主体中添加多余的美元符号,如下所示解决了该问题:
template_body = <<STACK ..Outputs: SecurityGroupId: Condition: CreateSecurityGroup Export: Name: !Sub $${VpcId}:$${Name}-tcp-$${Port}:id Value: !Ref SecurityGroup STACK }