Skip to content

Commit d4dad3b

Browse files
authored
Merge pull request #40 from JustFiesta/add-argocd-sec-groups
Add dev security groups for argocd access to backend pods
2 parents c7176e6 + 8123c99 commit d4dad3b

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
data "aws_security_groups" "backend_sg" {
2+
filter {
3+
name = "tag:service.eks.amazonaws.com/resource"
4+
values = ["ManagedBackendSecurityGroup"]
5+
}
6+
7+
filter {
8+
name = "vpc-id"
9+
values = [module.vpc.vpc_id]
10+
}
11+
12+
depends_on = [module.eks]
13+
}
14+
15+
data "aws_security_groups" "argocd_lb_sg" {
16+
filter {
17+
name = "tag:service.eks.amazonaws.com/stack"
18+
values = ["argocd/argocd-server"]
19+
}
20+
21+
filter {
22+
name = "vpc-id"
23+
values = [module.vpc.vpc_id]
24+
}
25+
26+
depends_on = [helm_release.argocd]
27+
}
28+
29+
resource "aws_security_group_rule" "argocd_backend_from_lb" {
30+
type = "ingress"
31+
from_port = 8080
32+
to_port = 8080
33+
protocol = "tcp"
34+
source_security_group_id = tolist(data.aws_security_groups.argocd_lb_sg.ids)[0]
35+
security_group_id = tolist(data.aws_security_groups.backend_sg.ids)[0]
36+
description = "Allow ArgoCD LoadBalancer to reach ArgoCD server pods"
37+
}
38+
39+
# Optional for tests: NGINX ingress controller
40+
data "aws_security_groups" "nginx_lb_sg" {
41+
filter {
42+
name = "tag:service.eks.amazonaws.com/stack"
43+
values = ["ingress-nginx/ingress-nginx-controller"]
44+
}
45+
46+
filter {
47+
name = "vpc-id"
48+
values = [module.vpc.vpc_id]
49+
}
50+
51+
depends_on = [helm_release.nginx_ingress]
52+
}
53+
54+
resource "aws_security_group_rule" "nginx_backend_from_lb_http" {
55+
type = "ingress"
56+
from_port = 80
57+
to_port = 80
58+
protocol = "tcp"
59+
source_security_group_id = tolist(data.aws_security_groups.nginx_lb_sg.ids)[0]
60+
security_group_id = tolist(data.aws_security_groups.backend_sg.ids)[0]
61+
description = "Allow NGINX LoadBalancer to reach NGINX ingress pods (HTTP)"
62+
}
63+
64+
resource "aws_security_group_rule" "nginx_backend_from_lb_https" {
65+
type = "ingress"
66+
from_port = 443
67+
to_port = 443
68+
protocol = "tcp"
69+
source_security_group_id = tolist(data.aws_security_groups.nginx_lb_sg.ids)[0]
70+
security_group_id = tolist(data.aws_security_groups.backend_sg.ids)[0]
71+
description = "Allow NGINX LoadBalancer to reach NGINX ingress pods (HTTPS)"
72+
}

0 commit comments

Comments
 (0)