Terraform

terraform code(sg)

KK_Ryong 2023. 9. 4. 11:06

#보안 그룹 생성------------------------------
resource "aws_security_group" "project-stg-api-alb-sg" {
  vpc_id = aws_vpc.project-stg-vpc.id
  name   = "project-stg-api-alb-sg"
  tags = {
    Name = "project-stg-api-alb-sg"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks = ["0.0.0.0/0"]
    description     = "http"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 443
    to_port     = 443
    cidr_blocks = ["0.0.0.0/0"]
    description     = "https"
  }
  
  egress {
    protocol    = "tcp"
    from_port   = 32768
    to_port     = 65535
    cidr_blocks = ["0.0.0.0/0"]
    description     = "ecs"
  }
  egress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks = ["0.0.0.0/0"]
  }
  egress {
    protocol    = "tcp"
    from_port   = 443
    to_port     = 443
    cidr_blocks = ["0.0.0.0/0"]
  }
  
  lifecycle {
    create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}
resource "aws_security_group" "project-stg-cron-alb-sg" {
  vpc_id = aws_vpc.project-stg-vpc.id
  name   = "project-stg-cron-alb-sg"
  tags = {
    Name = "project-stg-cron-alb-sg"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks = ["0.0.0.0/0"]
    description     = "http"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 443
    to_port     = 443
    cidr_blocks = ["0.0.0.0/0"]
    description     = "https"
  }
  egress {
    protocol    = "tcp"
    from_port   = 32768
    to_port     = 65535
    cidr_blocks = ["0.0.0.0/0"]
    description     = "ecs"
  }
  egress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks = ["0.0.0.0/0"]
  }
  egress {
    protocol    = "tcp"
    from_port   = 443
    to_port     = 443
    cidr_blocks = ["0.0.0.0/0"]
  }
  
  lifecycle {
    create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}
resource "aws_security_group" "project-stg-admin-alb-sg" {
  vpc_id = aws_vpc.project-stg-vpc.id
  name   = "project-stg-admin-alb-sg"
  tags = {
    Name = "project-stg-admin-alb-sg"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks = ["0.0.0.0/0"]
    description     = "http"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 443
    to_port     = 443
    cidr_blocks = ["0.0.0.0/0"]
    description     = "https"
  }
  
  egress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks = ["0.0.0.0/0"]
  }
  egress {
    protocol    = "tcp"
    from_port   = 443
    to_port     = 443
    cidr_blocks = ["0.0.0.0/0"]
  }
  egress {
    protocol    = "tcp"
    from_port   = 32768
    to_port     = 65535
    cidr_blocks = ["0.0.0.0/0"]
    description     = "ecs"
  }
  lifecycle {
    #create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}

#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
#보안 그룹 생성------------------------------
resource "aws_security_group" "project-stg-jenkins-alb-sg" {
  vpc_id = aws_vpc.project-stg-vpc.id
  name   = "project-stg-jenkins-alb-sg"
  tags = {
    Name = "project-stg-jenkins-alb-sg"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks = ["0.0.0.0/0"]
    description     = "http"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 443
    to_port     = 443
    cidr_blocks = ["0.0.0.0/0"]
    description     = "https"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 9090
    to_port     = 9090
    cidr_blocks = ["0.0.0.0/0"]
    description     = "jenkins"
  }
  egress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks = ["0.0.0.0/0"]
  }
  egress {
    protocol    = "tcp"
    from_port   = 443
    to_port     = 443
    cidr_blocks = ["0.0.0.0/0"]
  }
  egress {
    protocol    = "tcp"
    from_port   = 9090
    to_port     = 9090
    cidr_blocks = ["0.0.0.0/0"]
  }
  lifecycle {
    #create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
#보안 그룹 생성------------------------------
resource "aws_security_group" "project-stg-api-sg" {
  vpc_id = aws_vpc.project-stg-vpc.id
  name   = "project-stg-api-sg"
  tags = {
    Name = "project-stg-api-sg"
  }

  ingress {
    from_port   = 9100
    to_port     = 9100
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "node"
    }
  
  ingress {
    protocol    = "tcp"
    from_port   = 22
    to_port     = 22
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "ssh"
  }
  
  ingress {
    protocol    = "tcp"
    from_port   = 6379
    to_port     = 6379
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "redis"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 32768
    to_port     = 65535
    security_groups = [aws_security_group.project-stg-api-alb-sg.id]
    description     = "ecs"
  }
  
  egress {
    protocol    = "-1"
    from_port   = 0
    to_port     = 0
    cidr_blocks = ["0.0.0.0/0"]
  }
  lifecycle {
    #create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
#보안 그룹 생성------------------------------
resource "aws_security_group" "project-stg-cron-sg" {
  vpc_id = aws_vpc.project-stg-vpc.id
  name   = "project-stg-cron-sg"
  tags = {
    Name = "project-stg-cron-sg"
  }
  
  ingress {
    protocol    = "tcp"
    from_port   = 32768
    to_port     = 65535
    security_groups = [aws_security_group.project-stg-cron-alb-sg.id]
    description     = "ecs"
  }
  ingress {
    from_port   = 9100
    to_port     = 9100
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "node"
    }
  ingress {
    protocol    = "tcp"
    from_port   = 22
    to_port     = 22
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "ssh"
  }
  
  ingress {
    protocol    = "tcp"
    from_port   = 6379
    to_port     = 6379
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "redis"
  }
  egress {
    protocol    = "-1"
    from_port   = 0
    to_port     = 0
    cidr_blocks = ["0.0.0.0/0"]
  }
  lifecycle {
    #create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
#보안 그룹 생성------------------------------
resource "aws_security_group" "project-stg-admin-sg" {
  vpc_id = aws_vpc.project-stg-vpc.id
  name   = "project-stg-admin-sg"
  tags = {
    Name = "project-stg-admin-sg"
  }
  
  ingress {
    from_port   = 9100
    to_port     = 9100
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "node"
    }
  ingress {
    protocol    = "tcp"
    from_port   = 22
    to_port     = 22
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "ssh"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 32768
    to_port     = 65535
    security_groups = [aws_security_group.project-stg-admin-alb-sg.id]
    description     = "ecs"
  }
  
  ingress {
    protocol    = "tcp"
    from_port   = 6379
    to_port     = 6379
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "redis"
  }
  egress {
    protocol    = "-1"
    from_port   = 0
    to_port     = 0
    cidr_blocks = ["0.0.0.0/0"]
  }
  lifecycle {
    #create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
#보안 그룹 생성------------------------------
resource "aws_security_group" "project-stg-bastion-sg" {
  vpc_id = aws_vpc.project-stg-vpc.id
  name   = "project-stg-bastion-sg"
  tags = {
    Name = "project-stg-bastion-sg"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 22
    to_port     = 22
    cidr_blocks     = ["10.0.0.0/20","121.138.58.134/32","121.138.58.135/32"]
    description     = "ssh"
  }
  ingress {
    from_port   = 9100
    to_port     = 9100
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "node"
    }
  egress {
    protocol    = "tcp"
    from_port   = 22
    to_port     = 22
    cidr_blocks = ["10.0.0.0/20"]
    description     = "ssh"
  }
  egress {
    protocol    = "tcp"
    from_port   = 3306
    to_port     = 3306
    #cidr_blocks = ["10.0.0.0/20"]
    description     = "rds"
    security_groups = [aws_security_group.project-stg-rds.id]
  }
  egress {
    protocol    = "tcp"
    from_port   = 6379
    to_port     = 6379
    #cidr_blocks = ["10.0.0.0/20"]
    description     = "redis"
    security_groups = [aws_security_group.project-stg-redis.id]
  }
}
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
resource "aws_security_group" "project-stg-rds" {
    name    = "project-stg-rds-sg"
    vpc_id = aws_vpc.project-stg-vpc.id
    ingress {
    from_port   = 3306
    to_port     = 3306
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "mysql"
    }
    
    egress {
    protocol    = "tcp"
    from_port   = 3306
    to_port     = 3306
    cidr_blocks = ["10.0.0.0/20"]
    description     = "mysql"
  }
    tags = {
      Name = "project-stg-rds-sg"
    }
    
}

#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

resource "aws_security_group" "project-stg-jenkins" {
  vpc_id = aws_vpc.project-stg-vpc.id
  name   = "project-stg-jenkins-sg"
  tags = {
    Name = "project-stg-jenkins-sg"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 22
    to_port     = 22
    description     = "ssh"
    #cidr_blocks     = ["10.0.0.0/20"]
    security_groups = [aws_security_group.project-stg-bastion-sg.id]
  }
  ingress {
    protocol    = "tcp"
    from_port   = 9090
    to_port     = 9090
    description     = "jenkins"
    cidr_blocks     = ["10.0.0.0/20"]
  }
  ingress {
    from_port   = 9100
    to_port     = 9100
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "node"
    }
  egress {
    protocol    = "tcp"
    from_port   = 22
    to_port     = 22
    #cidr_blocks = ["10.0.0.0/20"]
    security_groups = [aws_security_group.project-stg-bastion-sg.id]
    description     = "ssh"
  }
  egress {
    protocol    = "-1"
    from_port   = 0
    to_port     = 0
    cidr_blocks = ["0.0.0.0/0"]
  }
}

#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
resource "aws_security_group" "project-stg-redis" {
    name    = "project-stg-redis-sg"
    vpc_id = aws_vpc.project-stg-vpc.id
    ingress {
    from_port   = 6379
    to_port     = 6379
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "redis"
    }
    
    egress {
    from_port   = 6379
    to_port     = 6379
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    }
    tags = {
      Name = "project-stg-redis-sg"
    }
    lifecycle {
    #create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
resource "aws_security_group" "project-stg-thumbor-sg" {
    name    = "project-stg-thumbor-sg"
    vpc_id = aws_vpc.project-stg-vpc.id
    ingress {
    protocol = "tcp"
    from_port= 22
    to_port  = 22
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "ssh"
    }
    
    ingress {
    from_port   = 9000
    to_port     = 9000
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    #security_groups = [aws_security_group.project-stg-thumbor-alb-sg.id]
    description     = "thumbor"
    }
    ingress {
    from_port   = 9100
    to_port     = 9100
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "node"
    }
    
    egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks     = ["0.0.0.0/0"]
  } 
    tags = {
      Name = "project-stg-thumbor-sg"
    }
    lifecycle {
    #create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
resource "aws_security_group" "project-stg-thumbor-alb-sg" {
    name    = "project-stg-thumbor-alb-sg"
    vpc_id = aws_vpc.project-stg-vpc.id
    ingress {
    from_port   = 80
    to_port     = 80
    protocol    = "tcp"
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "http"
    }
    
    ingress {
    from_port   = 443
    to_port     = 443
    protocol    = "tcp"
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "https"
    }
    
    egress {
    protocol    = "tcp"
    from_port   = 9000
    to_port     = 9000
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "thumbor"
    }
    egress {
    protocol    = "tcp"
    from_port   = 443
    to_port     = 443
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "https"
    }
    tags = {
      Name = "project-stg-thumbor-alb-sg"
    }
    lifecycle {
    #create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}
  
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  resource "aws_security_group" "project-stg-prometheus-sg" {
  vpc_id = aws_vpc.project-stg-vpc.id
  name   = "project-stg-prometheus-sg"
  tags = {
    Name = "project-stg-prometheus-sg"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 22
    to_port     = 22
    cidr_blocks = ["10.0.0.0/20"]
    description     = "ssh"
  }
  
  ingress {
    protocol    = "tcp"
    from_port   = 9100
    to_port     = 9100
    cidr_blocks = ["10.0.0.0/20"]
    #security_groups = [aws_security_group.project-stg-ecs-sg.id]
    description     = "node"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 9090
    to_port     = 9090
    cidr_blocks = ["10.0.0.0/20"]
    #security_groups = [aws_security_group.project-stg-ecs-sg.id]
    description     = "prometheus"
  }
  
  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks     = ["0.0.0.0/0"]
  }  
  
  lifecycle {
    #create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}

#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
resource "aws_security_group" "project-stg-prometheus-alb-sg" {
    name    = "project-stg-prometheus-alb-sg"
    vpc_id = aws_vpc.project-stg-vpc.id
    ingress {
    from_port   = 80
    to_port     = 80
    protocol    = "tcp"
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "http"
    }
    ingress {
    from_port   = 9090
    to_port     = 9090
    protocol    = "tcp"
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "https"
    }
    
    egress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "https"
    }
    egress {
    protocol    = "tcp"
    from_port   = 9090
    to_port     = 9090
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "https"
    }
    
    tags = {
      Name = "project-stg-prometheus-alb-sg"
    }
    lifecycle {
    #create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  resource "aws_security_group" "project-stg-grafana-sg" {
  vpc_id = aws_vpc.project-stg-vpc.id
  name   = "project-stg-grafana-sg"
  tags = {
    Name = "project-stg-grafana-sg"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 22
    to_port     = 22
    cidr_blocks = ["10.0.0.0/20"]
    description     = "ssh"
  }
  
  ingress {
    protocol    = "tcp"
    from_port   = 3000
    to_port     = 3000
    cidr_blocks = ["10.0.0.0/20"]
    #security_groups = [aws_security_group.project-stg-ecs-sg.id]
    description     = "node"
  }
  ingress {
    from_port   = 9100
    to_port     = 9100
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "node"
    }
  ingress {
    from_port   = 8081
    to_port     = 8081
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "renderer"
    }  
  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks     = ["0.0.0.0/0"]
  }  
  
  lifecycle {
    #create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}

#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
resource "aws_security_group" "project-stg-grafana-alb-sg" {
    name    = "project-stg-grafana-alb-sg"
    vpc_id = aws_vpc.project-stg-vpc.id
    ingress {
    from_port   = 80
    to_port     = 80
    protocol    = "tcp"
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "http"
    }
    ingress {
    from_port   = 3000
    to_port     = 3000
    protocol    = "tcp"
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "https"
    }
    
    egress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "https"
    }
    egress {
    protocol    = "tcp"
    from_port   = 3000
    to_port     = 3000
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "https"
    }
    
    tags = {
      Name = "project-stg-grafana-alb-sg"
    }
    lifecycle {
    #create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
resource "aws_security_group" "project-stg-push-sg" {
  vpc_id = aws_vpc.project-stg-vpc.id
  name   = "project-stg-push-sg"
  tags = {
    Name = "project-stg-push-sg"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 22
    to_port     = 22
    cidr_blocks = ["10.0.0.0/20"]
    description     = "ssh"
  }
  
  ingress {
    from_port   = 9100
    to_port     = 9100
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "node"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 6379
    to_port     = 6379
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "redis"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 32768
    to_port     = 65535
    security_groups = [aws_security_group.project-stg-push-alb-sg.id]
    description     = "ecs"
  }
  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks     = ["0.0.0.0/0"]
  }  
  
  lifecycle {
    #create_before_destroy = true
    #prevent_destroy = true  #삭제 방지 (오류로 떨어짐)
    #ignore_changes = all   #업데이트 방지
    }
}

#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
resource "aws_security_group" "project-stg-push-alb-sg" {
    name    = "project-stg-push-alb-sg"
    vpc_id = aws_vpc.project-stg-vpc.id
    ingress {
    from_port   = 80
    to_port     = 80
    protocol    = "tcp"
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "http"
    }
    ingress {
    protocol    = "tcp"
    from_port   = 443
    to_port     = 443
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "https"
    }
    egress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "https"
    }
    egress {
    protocol    = "tcp"
    from_port   = 443
    to_port     = 443
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "https"
    }
    egress {
    protocol    = "tcp"
    from_port   = 32768
    to_port     = 65535
    cidr_blocks = ["0.0.0.0/0"]
    description     = "ecs"
    }
    tags = {
      Name = "project-stg-push-alb-sg"
    }
    
}
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  resource "aws_security_group" "project-stg-chatting-sg" {
  vpc_id = aws_vpc.project-stg-vpc.id
  name   = "project-stg-chatting-sg"
  tags = {
    Name = "project-stg-chatting-sg"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 22
    to_port     = 22
    cidr_blocks = ["10.0.0.0/20"]
    description     = "ssh"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks = ["10.0.0.0/20"]
    description     = "http"
  }
  ingress {
    from_port   = 9100
    to_port     = 9100
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "node"
  }
  ingress {
    from_port   = 8008
    to_port     = 8008
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "synapse"
  }
  ingress {
    from_port   = 443
    to_port     = 443
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "synapse-admin"
  }
  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks     = ["0.0.0.0/0"]
  }  
  
}
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
resource "aws_security_group" "project-stg-chatting-alb-sg" {
    name    = "project-stg-chatting-alb-sg"
    vpc_id = aws_vpc.project-stg-vpc.id
    ingress {
    from_port   = 80
    to_port     = 80
    protocol    = "tcp"
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "http"
    }
    ingress {
    protocol    = "tcp"
    from_port   = 8008
    to_port     = 8008
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "https"
    }
    ingress {
    from_port   = 443
    to_port     = 443
    protocol    = "tcp"
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "synapse-admin"
    }
    egress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "https"
    }
    egress {
    protocol    = "tcp"
    from_port   = 8008
    to_port     = 8008
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "https"
    }
    egress {
    from_port   = 443
    to_port     = 443
    protocol    = "tcp"
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "synapse-admin"
    }
    tags = {
      Name = "project-stg-chatting-alb-sg"
    }
    
}
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
resource "aws_security_group" "project-stg-elk-sg" {
  vpc_id = aws_vpc.project-stg-vpc.id
  name   = "project-stg-elk-sg"
  tags = {
    Name = "project-stg-elk-sg"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 22
    to_port     = 22
    cidr_blocks = ["10.0.0.0/20"]
    description     = "ssh"
  }
  ingress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks = ["10.0.0.0/20"]
    description     = "http"
  }
  ingress {
    from_port   = 9100
    to_port     = 9100
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "node"
  }
  ingress {
    from_port   = 9200
    to_port     = 9200
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "elastic"
  }
  ingress {
    from_port   = 5601
    to_port     = 5601
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "kibana"
  }
  ingress {
    from_port   = 5044
    to_port     = 5044
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "logstash"
  }
  ingress {
    from_port   = 443
    to_port     = 443
    protocol    = "tcp"
    cidr_blocks     = ["10.0.0.0/20"]
    description     = "synapse-admin"
  }
  
  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks     = ["0.0.0.0/0"]
  }  
  
}
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
resource "aws_security_group" "project-stg-elk-alb-sg" {
    name    = "project-stg-elk-alb-sg"
    vpc_id = aws_vpc.project-stg-vpc.id
    ingress {
    from_port   = 80
    to_port     = 80
    protocol    = "tcp"
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "http"
    }
    
    ingress {
    from_port   = 443
    to_port     = 443
    protocol    = "tcp"
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "synapse-admin"
    }
    ingress {
    protocol    = "tcp"
    from_port   = 9200
    to_port     = 9200
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "elastic"
    }
    ingress {
    protocol    = "tcp"
    from_port   = 5601
    to_port     = 5601
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "kibana"
    }
    ingress {
    protocol    = "tcp"
    from_port   = 5044
    to_port     = 5044
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "logstash"
    }
    
    egress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "http"
    }
    egress {
    protocol    = "tcp"
    from_port   = 443
    to_port     = 443
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "https"
    }
    egress {
    protocol    = "tcp"
    from_port   = 9200
    to_port     = 9200
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "elastic"
    }
    egress {
    protocol    = "tcp"
    from_port   = 5601
    to_port     = 5601
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "kibana"
    }
    egress {
    protocol    = "tcp"
    from_port   = 5044
    to_port     = 5044
    cidr_blocks     = ["0.0.0.0/0"]
    description     = "logstash"
    }
    
    tags = {
      Name = "project-stg-elk-alb-sg"
    }
    
}