Skip to content

Instantly share code, notes, and snippets.

@blogumi
Created April 4, 2020 18:53
Show Gist options
  • Save blogumi/3aa27f8b337ae9758a4119401aaec1b0 to your computer and use it in GitHub Desktop.
Save blogumi/3aa27f8b337ae9758a4119401aaec1b0 to your computer and use it in GitHub Desktop.
This security group controls networking access to the Kubernetes masters. We will later configure this with an ingress rule to allow traffic from the worker nodes.
resource "aws_security_group" "demo-cluster" {
name = "terraform-eks-demo-cluster"
description = "Cluster communication with worker nodes"
vpc_id = "${aws_vpc.demo.id}"
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "terraform-eks-demo"
}
}
# OPTIONAL: Allow inbound traffic from your local workstation external IP
# to the Kubernetes. You will need to replace A.B.C.D below with
# your real IP. Services like icanhazip.com can help you find this.
resource "aws_security_group_rule" "demo-cluster-ingress-workstation-https" {
cidr_blocks = ["A.B.C.D/32"]
description = "Allow workstation to communicate with the cluster API Server"
from_port = 443
protocol = "tcp"
security_group_id = "${aws_security_group.demo-cluster.id}"
to_port = 443
type = "ingress"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment