将入口规则添加到terraform中的aws_security_group

时间:2016-09-20 21:59:33

标签: amazon-web-services terraform

我正在使用terraform 0.7.3。我创建了2个SG,并希望将入口规则添加到其中一个。

Workload看起来像这样:

1. $ tf plan (shows changes)
2. $ tf apply (applying changes)

太好了,我们回家......但不是真的:(

第二天,我在模板中添加了另一个入口规则,并且:

3. $ tf plan (shows new rule we'll be added and rules from point 2 will be removed [I don't know why].
4. $ tf apply (to see what happens and some rules are removed)
5. $ tf apply (everything is updated)

现在我可以运行'tf plan& tf应用'回到圈子里,所以事情会更新,但我不明白是什么打破了这个。

规则的代码如下:

resource "aws_security_group_rule" "Web1GIngress200" {
  type                     = "ingress"
  from_port                = 22
  to_port                  = 22
  protocol                 = "tcp"
  security_group_id        = "${aws_security_group.Web1SG.id}"
  source_security_group_id = "${aws_security_group.NATSG.id}"
}

任何建议表示赞赏,

谢谢

0 个答案:

没有答案