我在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,然后你必须用两个美元符号来转义插值。为
示例:${a}变为$${a}。
任何帮助都是非常感谢的。提前谢谢。
发布于 2019-11-07 08:07:01
错误消息确切地说明了您需要执行的操作:
"you must escape the interpolation with two dollar signs. For
example: ${a} becomes $${a}."意味着
VpcId = "${var.default_vpc_id}" 变成了
VpcId = "$${var.default_vpc_id}"发布于 2019-11-08 05:59:05
在模板体中添加了额外的美元符号,修复了这个问题:
template_body = <<STACK ..Outputs: SecurityGroupId: Condition: CreateSecurityGroup Export: Name: !Sub $${VpcId}:$${Name}-tcp-$${Port}:id Value: !Ref SecurityGroup STACK }
https://stackoverflow.com/questions/58739995
复制相似问题