Skip to content

Instantly share code, notes, and snippets.

@pporada-gl
Created January 3, 2017 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pporada-gl/f2f6af93b148a693fc6409bfcb7100d5 to your computer and use it in GitHub Desktop.
Save pporada-gl/f2f6af93b148a693fc6409bfcb7100d5 to your computer and use it in GitHub Desktop.
Terraform security group example
resource "aws_security_group" "jenkins" {
name = "${var.env}_${var.tier}_jenkins_secgroup"
vpc_id = "${var.vpc_id}"
description = "jenkins security group"
tags {
Name = "${var.env}_${var.tier}_jenkins_secgroup"
TERRAFORM = "true"
ENV = "${var.env}"
TIER = "${var.tier}"
}
ingress {
protocol = -1
from_port = 0
to_port = 0
cidr_blocks = ["${var.vpc_cidr}", "${split(",", var.peered_vpc_cidr)}"]
}
ingress {
protocol = "tcp"
from_port = 22
to_port = 22
cidr_blocks = ["${var.company_ip}"]
}
ingress {
protocol = "tcp"
from_port = 80
to_port = 80
cidr_blocks = [
"${var.company_ip}",
"${var.github_ip}",
"${var.some_ip}",
"${var.some_other_ip}"
]
}
ingress {
protocol = "tcp"
from_port = 443
to_port = 443
cidr_blocks = [
"${var.company_ip}",
"${var.github_ip}",
"${var.some_ip}",
"${var.some_other_ip}"
]
}
ingress {
from_port = 8
to_port = 0
protocol = "icmp"
cidr_blocks = ["${var.company_ip}"]
}
egress {
protocol = -1
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment