RDS Security Group 관리

RDS 접근을 위한 보안 그룹

RDS를 위한 Security Group 생성

  • DB 접근제어는 상당히 중요하기 때문에 별로도 관리해주시는 것이 필요합니다.

  • 같은 ingress port라고 하더라도 서로 다른 용도라고 하면, ingress block을 나눠서 작성하시는 것이 좋습니다.

  • 데이터베이스 기본 포트가 아닌 다른 포트를 사용하시는 것이 좋습니다.을 권장드립니다. ( 3306 -> 3900 )

vim terraform/databases/dayone-prod/dayonep_apnortheast2/dayone/sg.tf
# Database Security Group
# This security Group needs to be made before creating database
resource "aws_security_group" "dayone_aurora" {
  name        = "dayone-aurora-${data.terraform_remote_state.vpc.outputs.shard_id}"
  description = "dayone Aurora SG"
  vpc_id      = data.terraform_remote_state.vpc.outputs.vpc_id
  
  # Not using 3306 for mysql is recommended
  ingress {
    from_port = 3900
    to_port   = 3900 
    protocol  = "tcp"

    security_groups = []

    description = "Aurora whitelist from services."
  }
  
  ingress {
    from_port = 3900
    to_port   = 3900 
    protocol  = "tcp"

    security_groups = []

    description = "Aurora whitelist from xxx-vpc"
  }

  tags = {
    Name = "dayone-aurora-${data.terraform_remote_state.vpc.outputs.shard_id}"
  }
}

Last updated