From c97a117cba246d9127bd80d4b41dd902a54ed7c4 Mon Sep 17 00:00:00 2001 From: Scott Lowe Date: Mon, 23 Apr 2018 15:57:05 -0600 Subject: [PATCH] Fix errors Fix errors related to the addition of security groups to allow etcd traffic Signed-off-by: Scott Lowe --- etcd/etcdv3-ansible-aws-tf/main.tf | 40 +++++++++++++++++++----------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/etcd/etcdv3-ansible-aws-tf/main.tf b/etcd/etcdv3-ansible-aws-tf/main.tf index 3471754..395a3b4 100644 --- a/etcd/etcdv3-ansible-aws-tf/main.tf +++ b/etcd/etcdv3-ansible-aws-tf/main.tf @@ -11,31 +11,43 @@ module "etcd-vpc" { resource "aws_security_group" "etcd_sg" { name = "etcd_sg" description = "Allow traffic needed by etcd" - vpc_id = "${module.etcd-vpc.id}" + vpc_id = "${module.etcd-vpc.vpc_id}" } -resource "aws_security_group_rule" "etcd_sg_allow_sg" { +resource "aws_security_group_rule" "etcd_sg_allow_sg_in" { + security_group_id = "${aws_security_group.etcd_sg.id}" type = "ingress" from_port = 0 - to_port = 65535 - protocol = "tcp" + to_port = 0 + protocol = "-1" + source_security_group_id = "${aws_security_group.etcd_sg.id}" +} + +resource "aws_security_group_rule" "etcd_sg_allow_sg_out" { + security_group_id = "${aws_security_group.etcd_sg.id}" + type = "egress" + from_port = 0 + to_port = 0 + protocol = "-1" source_security_group_id = "${aws_security_group.etcd_sg.id}" } resource "aws_security_group_rule" "etcd_sg_allow_client" { - type = "ingress" - from_port = 2379 - to_port = 2379 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] + security_group_id = "${aws_security_group.etcd_sg.id}" + type = "ingress" + from_port = 2379 + to_port = 2379 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] } resource "aws_security_group_rule" "etcd_sg_allow_peer" { - type = "ingress" - from_port = 2380 - to_port = 2380 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] + security_group_id = "${aws_security_group.etcd_sg.id}" + type = "ingress" + from_port = 2380 + to_port = 2380 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] } module "etcd" {