IAM DB 인증 문제 해결 - Amazon Aurora

IAM DB 인증 문제 해결

여기에서는 몇 가지 일반적인 IAM DB 인증 문제에 대한 문제 해결 아이디어와 IAM DB 인증에 대한 CloudWatch 로그 관련 정보를 확인할 수 있습니다.

IAM DB 인증 오류 로그를 CloudWatch Logs로 내보내기

IAM DB 인증 오류 로그는 데이터베이스 호스트에 저장되며 이러한 로그를 CloudWatch Logs 계정으로 내보낼 수 있습니다. 이 페이지의 로그 및 문제 해결 방법을 사용하여 IAM DB 인증 문제를 해결합니다.

콘솔, AWS CLI 및 RDS API에서 CloudWatch Logs로 로그 내보내기를 사용 설정할 수 있습니다. 콘솔 지침은 Amazon CloudWatch Logs에 데이터베이스 로그 게시(을)를 참조하세요.

AWS CLI에서 DB 클러스터를 만들 때 IAM DB 인증 오류 로그를 CloudWatch Logs로 내보내려면 다음 명령을 사용합니다.

aws rds create-db-cluster --db-cluster-identifier mydbinstance \ --region us-east-1 \ --engine postgres \ --engine-version 16 \ --master-username master \ --master-user-password password \ --publicly-accessible \ --enable-iam-database-authentication \ --enable-cloudwatch-logs-exports=iam-db-auth-error

AWS CLI에서 DB 클러스터를 수정할 때 IAM DB 인증 오류 로그를 CloudWatch Logs로 내보내려면 다음 명령을 사용합니다.

aws rds modify-db-cluster --db-instance-identifier mydbcluster \ --region us-east-1 \ --cloudwatch-logs-export-configuration '{"EnableLogTypes":["iam-db-auth-error"]}'

DB 클러스터가 IAM DB 인증 로그를 CloudWatch Logs로 내보내고 있는지 확인하려면 describe-db-instances 명령의 출력에서 EnabledCloudwatchLogsExports 파라미터가 iam-db-auth-error로 설정되어 있는지 확인합니다.

aws rds describe-db-cluster --region us-east-1 --db-cluster-identifier mydbcluster ... "EnabledCloudwatchLogsExports": [ "iam-db-auth-error" ], ...

IAM DB 인증 CloudWatch 지표

Amazon Aurora는 IAM DB 인증에 대한 실시간에 가까운 지표를 Amazon CloudWatch 계정에 제공합니다. 다음 표에는 CloudWatch를 사용하여 사용할 수 있는 IAM DB 인증 지표가 나열되어 있습니다.

지표 설명

IamDbAuthConnectionRequests

IAM DB 인증으로 구성된 총 연결 요청 개수입니다.

IamDbAuthConnectionSuccess

성공한 IAM DB 인증 요청의 총 개수입니다.

IamDbAuthConnectionFailure

실패한 IAM DB 인증 요청의 총 개수입니다.

IamDbAuthConnectionFailureInvalidToken

유효하지 않은 토큰으로 인해 실패한 IAM DB 인증 요청의 총 개수입니다.

IamDbAuthConnectionFailureInsufficientPermissions

잘못된 정책 또는 권한으로 인해 실패한 IAM DB 인증 요청의 총 개수입니다.

IamDbAuthConnectionFailureThrottling

IAM DB 인증 스로틀링으로 인해 실패한 IAM DB 인증 요청의 총 개수입니다.

IamDbAuthConnectionFailureServerError

IAM DB 인증 기능의 내부 서버 오류로 인해 실패한 IAM DB 인증 요청의 총 개수입니다.

일반적인 문제 및 해결 방법

IAM DB 인증 사용 시 다음과 같은 문제가 발생할 수 있습니다. 표에 나와 있는 문제 해결 단계를 사용하여 문제를 해결합니다.

오류 지표 원인 솔루션

[ERROR] Failed to authenticate the connection request for user db_user because the provided token is malformed or otherwise invalid. (Status Code: 400, Error Code: InvalidToken)

IamDbAuthConnectionFailure

IamDbAuthConnectionFailureInvalidToken

연결 요청의 IAM DB 인증 토큰이 유효한 SigV4a 토큰이 아니거나 올바른 형식이 아닙니다.

애플리케이션에서 토큰 생성 전략을 확인합니다. 경우에 따라 토큰을 유효한 형식으로 전달해야 합니다. 토큰을 잘라내거나 잘못된 문자열 형식으로 지정하면 토큰이 무효화됩니다.

[ERROR] Failed to authenticate the connection request for user db_user because the token age is longer than 15 minutes. (Status Code: 400, Error Code:ExpiredToken)

IamDbAuthConnectionFailure

IamDbAuthConnectionFailureInvalidToken

IAM DB 인증 토큰이 만료되었습니다. 토큰은 15분 동안만 유효합니다.

애플리케이션에서 토큰 캐싱 및/또는 토큰 재사용 로직을 확인합니다. 15분보다 오래된 토큰은 재사용해서는 안 됩니다.

[ERROR] Failed to authorize the connection request for user db_user because the IAM policy assumed by the caller 'arn:aws:sts::123456789012:assumed-role/ <RoleName>/ <RoleSession>' is not authorized to perform `rds-db:connect` on the DB instance. (Status Code: 403, Error Code:NotAuthorized)

IamDbAuthConnectionFailure

IamDbAuthConnectionFailureInsufficientPermissions

이 오류는 다음과 같은 이유 때문일 수 있습니다.

  • 애플리케이션에서 수임하는 IAM 정책은 rds-db:connect 작업을 승인하지 않습니다.

  • db_user가 데이터베이스에 연결하는 데 잘못된 역할/정책을 수임하고 있습니다.

  • db_user에 대해 올바른 정책을 수임하고 있지만 올바른 데이터베이스에 연결되어 있지 않습니다.

애플리케이션에서 수임하는 IAM 역할 및/또는 정책을 확인합니다. DB에 연결할 때와 동일한 정책을 수임하여 토큰을 생성해야 합니다.

[ERROR] Failed to authorize the connection request for user db_user due to IAM DB authentication throttling. (Status Code: 429, Error Code: ThrottlingException)

IamDbAuthConnectionFailure

IamDbAuthConnectionFailureThrottling

짧은 시간 내에 DB에 너무 많은 연결 요청을 하고 있습니다. IAM DB 인증 스로틀링 한도는 초당 200개의 연결입니다.

IAM 인증으로 새 연결을 설정하는 속도를 줄입니다. 애플리케이션에서 설정된 연결을 재사용하려면 RDS 프록시를 사용하여 연결 풀링을 구현하는 것이 좋습니다.

[ERROR] Failed to authorize the connection request for user db_user due to an internal IAM DB authentication error. (Status Code: 500, Error Code: InternalError)

IamDbAuthConnectionFailure

IamDbAuthConnectionFailureThrottling

IAM DB 인증으로 DB 연결을 승인하는 동안 내부 오류가 발생했습니다.

문제를 조사하려면 https://aws.amazon.com/premiumsupport/를 통해 문의하시기 바랍니다.