설명
Redshift의 연결과 사용자 활동을 장기간 조사하려면 감사 로그를 S3 또는 CloudWatch Logs로 전송하세요.
잠재적 영향
외부 기록이 없으면 데이터베이스에 남은 기록보다 오래된 접속이나 관리 작업을 조사하기 어렵습니다.
해결 방법
aws_redshift_logging에 대상 클러스터와 목적지를 지정하세요. cloudwatch를 사용하면 log_exports에 로그 유형을 지정하세요. SQL 활동도 기록하려면 클러스터의 enable_user_activity_logging을 켜세요. connectionlog라면 새 접속 기록처럼 선택한 유형의 이벤트가 도착하는지 확인하고 열람 권한과 보존 기간을 정하세요.
예시
예시는 기존 클러스터에 S3 전송을 추가합니다. 버킷과 전송 정책을 준비하고 서로 호환되는 노드·클러스터 유형을 변수로 전달하세요. 운영 비밀번호는 별도로 관리하고 Terraform 상태 파일의 접근 권한을 제한하세요.
변경 전
hcl
resource "aws_redshift_cluster" "example" {
cluster_identifier = "tf-redshift-cluster"
database_name = "mydb"
master_username = "foo"
master_password = "Mustbe8characters"
node_type = var.redshift_node_type
cluster_type = var.redshift_cluster_type
}
변경 후
hcl
resource "aws_redshift_cluster" "example" {
cluster_identifier = "tf-redshift-cluster"
database_name = "mydb"
master_username = "foo"
master_password = "Mustbe8characters"
node_type = var.redshift_node_type
cluster_type = var.redshift_cluster_type
}
resource "aws_redshift_logging" "example" {
cluster_identifier = aws_redshift_cluster.example.id
log_destination_type = "s3"
bucket_name = aws_s3_bucket.logs.id
}