Skip to content

Instantly share code, notes, and snippets.

@swade1987
Created June 1, 2016 12:35
Show Gist options
  • Save swade1987/d3ac437aa40ee3216247c53a20982fef to your computer and use it in GitHub Desktop.
Save swade1987/d3ac437aa40ee3216247c53a20982fef to your computer and use it in GitHub Desktop.
curl -v http://<instance ip>:2375
* Rebuilt URL to: http://<instance ip>:2375/
* Hostname was NOT found in DNS cache
* Trying <instance ip>...
# ====== Security group for traffic into the ELB ====== #
resource "aws_security_group" "ingress_to_elb" {
name = "search-for-member - traffic to elb"
description = "search-for-member - traffic to elb"
vpc_id = "${var.vpc_id}"
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["${var.ingress_cidr_blocks}"]
}
ingress {
from_port = 2375
to_port = 2375
protocol = "tcp"
cidr_blocks = ["${var.ingress_cidr_blocks}"]
}
}
# ====== Security group for traffic from the ELB ====== #
resource "aws_security_group" "egress_from_elb" {
name = "search-for-member - traffic from elb"
description = "search-for-member - traffic from elb"
vpc_id = "${var.vpc_id}"
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["${var.ingress_cidr_blocks}"]
}
}
# ====== Security group for traffic into the instances. ====== #
resource "aws_security_group" "ingress_to_instances" {
name = "search-for-member - traffic to instances"
description = "search-for-member - traffic to instances"
vpc_id = "${var.vpc_id}"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["${var.ingress_cidr_blocks}"]
}
# HTTP from ELB
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
security_groups = ["${aws_elb.search_for_member.source_security_group_id}"]
}
ingress {
from_port = 2375
to_port = 2375
protocol = "tcp"
security_groups = ["${aws_elb.search_for_member.source_security_group_id}"]
}
ingress {
from_port = 2375
to_port = 2375
protocol = "tcp"
cidr_blocks = ["${var.ingress_cidr_blocks}"]
}
}
# ====== Security group for traffic from the instances. ====== #
resource "aws_security_group" "egress_from_instances" {
name = "search-for-member - traffic from instances"
description = "search-for-member - traffic from instances"
vpc_id = "${var.vpc_id}"
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["${var.ingress_cidr_blocks}"]
}
}
resource "aws_security_group" "swarm_manager" {
name = "swarm-manager-security-group"
description = "Security group for Swarm Manager"
ingress {
from_port = 4000
to_port = 4000
protocol = "tcp"
cidr_blocks = ["${var.ingress_cidr_blocks}"]
}
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["${var.ingress_cidr_blocks}"]
}
ingress {
from_port = 0
to_port = 0
protocol = "-1"
self = true
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["${var.ingress_cidr_blocks}"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment