aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'infra/sg.tf')
-rw-r--r--infra/sg.tf38
1 files changed, 38 insertions, 0 deletions
diff --git a/infra/sg.tf b/infra/sg.tf
new file mode 100644
index 0000000..48d5406
--- /dev/null
+++ b/infra/sg.tf
@@ -0,0 +1,38 @@
1# EC 2
2resource "aws_security_group" "backend" {
3 name = local.name
4 vpc_id = module.vpc.vpc_id
5}
6
7resource "aws_security_group_rule" "backend_ingress_ssh" {
8 security_group_id = aws_security_group.backend.id
9 type = "ingress"
10 protocol = "tcp"
11 from_port = 22
12 to_port = 22
13 cidr_blocks = ["0.0.0.0/0"]
14}
15
16resource "aws_security_group_rule" "backend_egress_all" {
17 security_group_id = aws_security_group.backend.id
18 type = "egress"
19 protocol = "all"
20 from_port = 0
21 to_port = 0
22 cidr_blocks = ["0.0.0.0/0"]
23}
24
25# RDS
26resource "aws_security_group" "rds" {
27 name = "${local.name}-db"
28 vpc_id = module.vpc.vpc_id
29}
30
31resource "aws_security_group_rule" "rds_ingress_backend" {
32 security_group_id = aws_security_group.rds.id
33 type = "ingress"
34 protocol = "tcp"
35 from_port = var.rds_port
36 to_port = var.rds_port
37 source_security_group_id = aws_security_group.backend.id
38}
Powered by cgit v1.2.3 (git 2.41.0)