Ongoing service disruptions
For the most recent update on ongoing service disruptions affecting the AWS Middle East (UAE) Region (ME-CENTRAL-1), refer to the AWS Health Dashboard. For information on AWS Service migration, see How do I migrate my services to another region?
누가 EC2 인스턴스에서 EBS 볼륨을 삭제했는가와 같이 CloudTrail을 사용하여 특정 리소스에 대한 작업을 검색하려면 어떻게 해야 합니까?
AWS CloudTrail을 사용하여 특정 리소스에서 정보를 검색하고 싶습니다.
해결 방법
중요:
- 조회 요청 비율은 계정별로 초당 1개의 요청으로 제한됩니다. 이 한도를 초과하면 제한 오류가 발생합니다.
- 이벤트가 발생하기 전에 CloudTrail 로깅이 켜져 있는지 확인합니다. 그렇지 않으면 이벤트가 발생한 시간 범위 동안에는 이벤트를 조회할 수 없습니다.
- AWS 서비스는 계속해서 이벤트를 추가할 수 있습니다. CloudTrail은 이벤트 기록에 이벤트를 기록합니다.
- AWS Command Line Interface(AWS CLI) 명령을 실행할 때 오류가 발생하는 경우 최신 AWS CLI 버전을 사용하고 있는지 확인합니다.
다음 예제는 AWS CLI에서 실행됩니다. 이러한 명령의 대부분은 명령줄 JSON 프로세서인 jq를 사용합니다. jq에 대한 자세한 내용은jq 웹 사이트를 참조하세요.
Amazon Linux 에 jq를 설치하려면 yum을 사용합니다.
yum install jq
**참고:**다른 플랫폼을 위한 jq 설치 옵션이 있습니다. jq 설치 옵션에 대한 자세한 내용은 jq 웹 사이트에서 jq 다운로드를 참조하세요.
특정 리소스의 모든 이벤트 이름 나열
다음 예에서는 Amazon EBS(Amazon Elastic Block Store) 볼륨 ID를 사용하여 API 작업에 대한 최근 이벤트 목록을 가져옵니다. vol-0f59a355c2example의 AttributeValue를 볼륨 ID 로, us-east-1을 사용자 리전으로 바꿉니다.
$ aws cloudtrail lookup-events --lookup-attributes AttributeKey=ResourceName,AttributeValue=vol-0f59a355c2example --query 'Events[].{username:Username,time:EventTime,event:EventName,eventid:EventId,accesskey:AccessKeyId,resource:(Resources[0].ResourceName)}' --output table --region us-east-1
**참고:**CloudTrail이 최근 호출을 채우는 데 예상보다 오래 걸릴 수 있습니다.
EBS 스냅샷과 같은 다른 리소스 ID를 사용하여 동일한 예제를 실행할 수 있습니다. snap-0993c0d9a8example의 AttributeValue를 스냅샷 ID로, us-east-1을 사용자 리전으로 바꿉니다.
$ aws cloudtrail lookup-events --lookup-attributes AttributeKey=ResourceName,AttributeValue=snap-0993c0d9a8example --query 'Events[].{username:Username,time:EventTime,event:EventName,eventid:EventId,accesskey:AccessKeyId,resource:(Resources[0].ResourceName)}' --output table --region us-east-1
특정 리소스의 특정 API 작업에 대한 이벤트 목록
다음 예에서는 EBS 볼륨에 대한 DeleteVolume API 작업에 대한 최근 이벤트 목록을 가져오는 방법을 보여 줍니다. vol-0f59a355c2example의 AttributeValue을 볼륨 ID로 바꿉니다.
$ aws cloudtrail lookup-events --lookup-attributes AttributeKey=ResourceName,AttributeValue=vol-0f59a355c2example --query 'Events[].{username:Username,time:EventTime,event:EventName,eventid:EventId,accesskey:AccessKeyId,resource:(Resources[0].ResourceName)}' --output json --region us-east-1 | jq -r '.[] | select(.event == "DeleteVolume")'
출력 예시:
{ "username": "jdoe", "eventid": "e3ec4051-9999-4e87-9999-9cc72example", "resource": "vol-0f59a355c2example", "accesskey": "ASIAXUZVKEUACEXAMPLE", "time": 1550191014, "event": "DeleteVolume" }
모든 리소스에 대한 특정 이벤트 이름 나열
다음 예에서는 DeleteVolume 이벤트 이름을 필터로 사용하여 삭제된 EBS 볼륨을 나열합니다. us-east-1을 사용자 리전으로 바꿉니다.
$ aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=DeleteVolume --query 'Events[].{username:Username,time:EventTime,event:EventName,eventid:EventId,accesskey:AccessKeyId,resource:(Resources[0].ResourceName)}' --output table --region us-east-1
모든 리소스에 대해 종료된 EC2 인스턴스 나열
다음 예제에서는 최근 EC2 TerminateInstances를 보여 줍니다. -region us-east-1을 사용자 리전으로 바꿉니다.
$ aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=TerminateInstances --query 'Events[].{username:Username,time:EventTime,event:EventName,eventid:EventId,accesskey:AccessKeyId,resource:(Resources[0].ResourceName)}' --output table --region us-east-1
특정 이벤트 ID에 대한 세부 정보 보기
이벤트 ID를 찾으면 이 이벤트에 대한 세부 정보를 볼 수 있습니다. 0840b15f-75b5-4082-a194-86e15example 의AttributeValue를 이벤트 ID 로, us-east-1을 사용자 리전으로 바꿉니다.
$ aws cloudtrail lookup-events --query "Events[0].CloudTrailEvent" --output text --lookup-attribute AttributeKey=EventId,AttributeValue=0840b15f-75b5-4082-a194-86e15example --region us-east-1 | jq -r '.'
출력 예시:
{ "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "AROAJ3THTCWDOKEXAMPLE:jdoe", "arn": "arn:aws:sts::52570EXAMPLE:assumed-role/Admin/jdoe", "accountId": "52570example", "accessKeyId": "ASIAXUZVKEUAKEXAMPLE", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2019-02-14T23:55:15Z" }, "sessionIssuer": { "type": "Role", "principalId": "AROAJ3THTCWDOKEXAMPLE", "arn": "arn:aws:iam::52570EXAMPLE:role/Admin", "accountId": "52570EXAMPLE", "userName": "Admin" } } }, "eventTime": "2019-02-15T00:48:05Z", "eventSource": "ec2.amazonaws.com", "eventName": "DeleteVolume", "awsRegion": "us-east-1", "sourceIPAddress": "999.999.999.999", "userAgent": "aws-cli/1.16.999 Python/2.7.15 Darwin/17.7.0 botocore/1.12.91", "requestParameters": { "volumeId": "vol-0c50d65c6eexample" }, "responseElements": { "_return": true }, "requestID": "a8a43ccd-736d-4b09-ba75-24b9cexample", "eventID": "0840b15f-75b5-4082-a194-86e15example", "eventType": "AwsApiCall", "recipientAccountId": "52570EXAMPLE" }
날짜 범위 지정
이벤트의 날짜 범위를 지정하려면 --start-time 및 --end-time 매개변수를 사용합니다.
$ aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=DeleteVolume --query 'Events[].{username:Username,time:EventTime,event:EventName,eventid:EventId,accesskey:AccessKeyId,resource:(Resources[0].ResourceName)}' --output table --region us-east-1 --start-time 2019-01-01T13:00Z --end-time 2019-03-01T14:00Z
참고:유효한 타임스탬프 형식의 목록에서 원하는 타임스탬프를 선택합니다.
나열된 이벤트는 시작 시간 이후부터 종료 시간까지 발생합니다.
기본 시작 시간은 최근 90일 이내에 데이터를 사용할 수 있는 가장 빠른 날짜입니다. 기본 종료 시간은 현재 시간에 가장 가까운 시점에 발생한 이벤트의 시간입니다. 지정된 시작 시간이 지정된 종료 시간 이후이면 InvalidTimeRangeException 오류가 반환됩니다.
관련 콘텐츠
- 질문됨 일 년 전
