Amazon EventBridge로 IAM Access Analyzer 모니터링
Amazon EventBridge로 IAM Access Analyzer 모니터링
이 문서에서는 Amazon EventBridge로 IAM Access Analyzer 결과(finding)와 접근 미리 보기(access preview)를 모니터링하는 방법을 예시 이벤트와 이벤트 규칙 패턴과 함께 설명합니다.
출처: 문서
본문
이 주제의 정보를 사용해 Amazon EventBridge로 IAM Access Analyzer 결과와 접근 미리 보기를 모니터링하는 방법을 배울 수 있어요. EventBridge는 Amazon CloudWatch Events의 새 버전입니다.
결과 이벤트
IAM Access Analyzer는 생성된 각 결과, 기존 결과의 상태 변경, 결과 삭제 시 EventBridge에 이벤트를 보냅니다. 결과 및 결과에 대한 알림을 받으려면 Amazon EventBridge에서 이벤트 규칙을 만들어야 합니다. 이벤트 규칙을 만들 때 규칙에 따라 트리거할 대상(target) 작업도 지정할 수 있어요. 예를 들어 IAM Access Analyzer에서 새 결과에 대한 이벤트를 수신하면 Amazon SNS 주제를 트리거하는 이벤트 규칙을 만들 수 있습니다. 리소스 제어 정책(RCP)에 대한 세부 정보는 이벤트 세부 정보(detail) 섹션에서 확인할 수 있습니다.
IAM Access Analyzer는 각 접근 미리 보기와 상태 변경에 대해 EventBridge에 이벤트를 보냅니다. 여기에는 접근 미리 보기가 처음 생성될 때(Creating 상태), 완료될 때(Completed 상태), 생성이 실패했을 때(Failed 상태) 이벤트가 포함됩니다. 접근 미리 보기에 대한 알림을 받으려면 EventBridge에서 이벤트 규칙을 만들어야 합니다. 이벤트 규칙을 만들 때 규칙에 따라 트리거할 대상 작업을 지정할 수 있어요. 예를 들어 IAM Access Analyzer에서 완료된 접근 미리 보기에 대한 이벤트를 수신하면 Amazon SNS 주제를 트리거하는 이벤트 규칙을 만들 수 있습니다.
이벤트 알림 빈도
IAM Access Analyzer는 계정에서 이벤트가 발생한 시점부터 약 1시간 이내에 새 결과와 상태가 업데이트된 결과의 이벤트를 EventBridge로 보냅니다. IAM Access Analyzer는 보존 기간이 만료되어 해결된 결과가 삭제될 때도 EventBridge에 이벤트를 보냅니다. 결과를 생성한 분석기가 삭제되어 결과가 삭제되는 경우, 이벤트는 분석기 삭제 후 약 24시간 뒤에 EventBridge로 전송됩니다. 결과가 삭제될 때 결과 상태는 변경되지 않습니다. 대신 isDeleted 속성이 true로 설정됩니다. IAM Access Analyzer는 새로 생성된 접근 미리 보기와 접근 미리 보기 상태 변경에 대한 이벤트도 EventBridge로 보냅니다.
외부 접근 결과 이벤트 예시
다음은 EventBridge로 보내진 IAM Access Analyzer 외부 접근 결과 이벤트 예시입니다. 나열된 id는 EventBridge의 이벤트 ID입니다. 자세한 내용은 EventBridge의 이벤트 및 이벤트 패턴을 참고하세요.
detail 객체에서 accountId와 region 속성의 값은 결과에 보고된 계정·리전을 나타냅니다. isDeleted 속성은 이벤트가 결과 삭제에서 온 것인지 나타냅니다. id는 결과 ID입니다. resources 배열은 결과를 생성한 분석기의 ARN이 담긴 단일 요소 배열입니다.
{
"account": "111122223333",
"detail": {
"accountId": "111122223333",
"action": [
"s3:GetObject"
],
"analyzedAt": "2019-11-21T01:22:22Z",
"condition": {},
"createdAt": "2019-11-20T04:58:50Z",
"id": "22222222-dcba-4444-dcba-333333333333",
"isDeleted": false,
"isPublic": false,
"principal": {
"AWS": "999988887777"
},
"region": "us-west-2",
"resource": "arn:aws:s3:::amzn-s3-demo-bucket",
"resourceType": "AWS::S3::Bucket",
"status": "ACTIVE",
"updatedAt": "2019-11-21T01:14:07Z",
"version": "1.0"
},
"detail-type": "Access Analyzer Finding",
"id": "11111111-2222-4444-aaaa-333333333333",
"region": "us-west-2",
"resources": [
"arn:aws:access-analyzer:us-west-2:111122223333:analyzer/MyAnalyzer"
],
"source": "aws.access-analyzer",
"time": "2019-11-21T01:22:33Z",
"version": "0"
}
IAM Access Analyzer는 오류 결과에 대해서도 EventBridge에 이벤트를 보냅니다. 오류 결과는 IAM Access Analyzer가 리소스를 분석할 수 없을 때 생성됩니다. 오류 결과에 대한 이벤트는 다음 예시와 같이 error 속성을 포함합니다.
{
"account": "111122223333",
"detail": {
"accountId": "111122223333",
"analyzedAt": "2019-11-21T01:22:22Z",
"createdAt": "2019-11-20T04:58:50Z",
"error": "ACCESS_DENIED",
"id": "22222222-dcba-4444-dcba-333333333333",
"isDeleted": false,
"region": "us-west-2",
"resource": "arn:aws:s3:::amzn-s3-demo-bucket",
"resourceType": "AWS::S3::Bucket",
"status": "ACTIVE",
"updatedAt": "2019-11-21T01:14:07Z",
"version": "1.0"
},
"detail-type": "Access Analyzer Finding",
"id": "11111111-2222-4444-aaaa-333333333333",
"region": "us-west-2",
"resources": [
"arn:aws:access-analyzer:us-west-2:111122223333:analyzer/MyAnalyzer"
],
"source": "aws.access-analyzer",
"time": "2019-11-21T01:22:33Z",
"version": "0"
}
내부 접근 결과 이벤트 예시
다음은 EventBridge로 보내진 IAM Access Analyzer 내부 접근 결과 이벤트 예시입니다. 나열된 id는 EventBridge의 이벤트 ID입니다. 자세한 내용은 EventBridge의 이벤트 및 이벤트 패턴을 참고하세요.
detail 객체에서 accountId와 principalOwnerAccount 속성의 값은 결과에 보고된 주체의 계정을 나타냅니다. isDeleted 속성은 이벤트가 결과 삭제에서 온 것인지 나타냅니다. id는 결과 ID입니다. resource는 결과를 생성한 분석기의 ARN입니다.
{
"version": "0",
"id": "b45c3678-c278-b593-6121-c155259ce1b5",
"detail-type": "Internal Access Finding",
"source": "aws.access-analyzer",
"account": "111122223333",
"time": "2025-04-08T19:42:49Z",
"region": "us-east-1",
"resources": [
"arn:aws:access-analyzer:us-east-1:111122223333:analyzer/testAnalyzer"
],
"detail": {
"accessType": "INTRA_ACCOUNT",
"action": [
"s3:GetObject"
],
"analyzedAt": "2025-04-08T03:18:43.509465073Z",
"condition": {},
"createdAt": "2025-04-07T21:33:49.914099224Z",
"id": "11111111-2222-4444-aaaa-333333333333",
"isDeleted": false,
"findingType": "InternalAccess",
"principal": {
"AWS": "arn:aws:iam::111122223333:role/MyRole_6"
},
"principalOwnerAccount": "111122223333",
"principalType": "IAM_ROLE",
"resource": "arn:aws:s3:::critical-data",
"resourceControlPolicyRestrictionType": "NOT_APPLICABLE",
"accountId": "111122223333",
"resourceType": "AWS::S3::Bucket",
"serviceControlPolicyRestrictionType": "NOT_APPLICABLE",
"status": "ACTIVE",
"updatedAt": "2025-04-08T03:22:12.654688231Z",
"version": "1.0"
}
}
IAM Access Analyzer는 오류 결과에 대해서도 EventBridge에 이벤트를 보냅니다. 오류 결과는 IAM Access Analyzer가 리소스를 분석할 수 없을 때 생성됩니다. 오류 결과에 대한 이벤트는 다음 예시와 같이 error 속성을 포함합니다.
{
"version": "0",
"id": "5a94b99b-e87d-a6a7-58c7-f47871532860",
"detail-type": "Internal Access Finding",
"source": "aws.access-analyzer-test",
"account": "444455556666",
"time": "2025-05-07T11:57:54Z",
"region": "us-west-2",
"resources": ["arn:aws:access-analyzer-beta:us-west-2:444455556666:analyzer/example-analyzer"],
"detail": {
"analyzedAt": "2025-03-24T19:58:52.512329448Z",
"createdAt": "2025-03-22T03:30:46.920200692Z",
"id": "ef573afd-12a5-4095-87a6-bf2f25109895",
"isDeleted": false,
"findingType": "InternalAccess",
"resource": "arn:aws:s3:::test-entity-88",
"accountId": "111122223333",
"resourceControlPolicyRestrictionType": "NOT_APPLICABLE",
"resourceType": "AWS::S3::Bucket",
"serviceControlPolicyRestrictionType": "NOT_APPLICABLE",
"error": "ACCESS_DENIED", // can be INTERNAL_ERROR and ACCESS_DENIED
"status": "ACTIVE",
"updatedAt": "2025-03-24T20:09:39.176075014Z",
"version": "1.0"
}
}
미사용 접근 결과 관련 이벤트 예시
다음은 EventBridge로 보내진 IAM Access Analyzer 미사용 접근 결과 이벤트 예시입니다. 나열된 id는 EventBridge의 이벤트 ID입니다. 자세한 내용은 EventBridge의 이벤트 및 이벤트 패턴을 참고하세요.
detail 객체에서 accountId와 region 속성의 값은 결과에 보고된 계정·리전을 나타냅니다. isDeleted 속성은 이벤트가 결과 삭제에서 온 것인지 나타냅니다. id는 결과 ID입니다.
{
"version": "0",
"id": "dc7ce3ee-114b-3243-e249-7f10f9054b21",
"detail-type": "Unused Access Finding for IAM entities",
"source": "aws.access-analyzer",
"account": "123456789012",
"time": "2023-09-29T17:31:40Z",
"region": "us-west-2",
"resources": [
"arn:aws:access-analyzer:us-west-2:123456789012:analyzer/integTestLongLivingAnalyzer-DO-NOT-DELETE"
],
"detail": {
"findingId": "b8ae0460-5d29-4922-b92a-ba956c986277",
"resource": "arn:aws:iam::111122223333:role/FindingIntegTestFakeRole",
"resourceType": "AWS::IAM::Role",
"accountId": "111122223333",
"createdAt": "2023-09-29T17:29:18.758Z",
"updatedAt": "2023-09-29T17:29:18.758Z",
"analyzedAt": "2023-09-29T17:29:18.758Z",
"previousStatus": "",
"status": "ACTIVE",
"version": "62160bda-8e94-46d6-ac97-9670930d8ffb",
"isDeleted": false,
"findingType": "UnusedPermission",
"numberOfUnusedServices": 0,
"numberOfUnusedActions": 1
}
}
IAM Access Analyzer는 오류 결과에 대해서도 EventBridge에 이벤트를 보냅니다. 오류 결과는 IAM Access Analyzer가 리소스를 분석할 수 없을 때 생성됩니다. 오류 결과에 대한 이벤트는 다음 예시와 같이 error 속성을 포함합니다.
{
"version": "0",
"id": "c2e7aa1a-4df7-7652-f33e-64113b8997d4",
"detail-type": "Unused Access Finding for IAM entities",
"source": "aws.access-analyzer",
"account": "111122223333",
"time": "2023-10-31T20:26:12Z",
"region": "us-west-2",
"resources": [
"arn:aws:access-analyzer:us-west-2:111122223333:analyzer/ba811f91-de99-41a4-97c0-7481898b53f2"
],
"detail": {
"findingId": "b01a34f2-e118-46c9-aef8-0d8526b495c7",
"resource": "arn:aws:iam::123456789012:role/TestRole",
"resourceType": "AWS::IAM::Role",
"accountId": "444455556666",
"createdAt": "2023-10-31T20:26:08.647Z",
"updatedAt": "2023-10-31T20:26:09.245Z",
"analyzedAt": "2023-10-31T20:26:08.525Z",
"previousStatus": "",
"status": "ACTIVE",
"version": "7c7a72a2-7963-4c59-ac71-f0be597010f7",
"isDeleted": false,
"findingType": "UnusedIAMRole",
"error": "INTERNAL_ERROR"
}
}
다음 예시는 접근 미리 보기를 만들 때 EventBridge로 전송되는 첫 번째 이벤트의 데이터를 보여 줍니다. resources 배열은 접근 미리 보기와 연결된 분석기의 ARN이 담긴 단일 요소 배열입니다. detail 객체에서 id는 접근 미리 보기 ID를, configuredResources는 접근 미리 보기가 생성된 리소스를 나타냅니다. status는 Creating이며 접근 미리 보기 상태를 나타냅니다. previousStatus는 접근 미리 보기가 방금 생성되었기 때문에 지정되지 않습니다.
{
"account": "111122223333",
"detail": {
"accessPreviewId": "aaaabbbb-cccc-dddd-eeee-ffffaaaabbbb",
"configuredResources": [
"arn:aws:s3:::amzn-s3-demo-bucket"
],
"createdAt": "2020-02-20T00:00:00.00Z",
"region": "us-west-2",
"status": "CREATING",
"version": "1.0"
},
"detail-type": "Access Preview State Change",
"id": "aaaabbbb-2222-3333-4444-555566667777",
"region": "us-west-2",
"resources": [
"arn:aws:access-analyzer:us-west-2:111122223333:analyzer/MyAnalyzer"
],
"source": "aws.access-analyzer",
"time": "2020-02-20T00:00:00.00Z",
"version": "0"
}
다음 예시는 접근 미리 보기의 상태가 Creating에서 Completed로 변경될 때 EventBridge로 전송되는 이벤트의 데이터를 보여 줍니다. detail 객체에서 id는 접근 미리 보기 ID를 나타냅니다. status와 previousStatus는 접근 미리 보기 상태를 나타내는데, 이전 상태는 Creating이고 현재 상태는 Completed입니다.
{
"account": "111122223333",
"detail": {
"accessPreviewId": "aaaabbbb-cccc-dddd-eeee-ffffaaaabbbb",
"configuredResources": [
"arn:aws:s3:::amzn-s3-demo-bucket"
],
"createdAt": "2020-02-20T00:00:00.000Z",
"previousStatus": "CREATING",
"region": "us-west-2",
"status": "COMPLETED",
"version": "1.0"
},
"detail-type": "Access Preview State Change",
"id": "11112222-3333-4444-5555-666677778888",
"region": "us-west-2",
"resources": [
"arn:aws:access-analyzer:us-west-2:111122223333:analyzer/MyAnalyzer"
],
"source": "aws.access-analyzer",
"time": "2020-02-20T00:00:00.00Z",
"version": "0"
}
다음 예시는 접근 미리 보기의 상태가 Creating에서 Failed로 변경될 때 EventBridge로 전송되는 이벤트의 데이터를 보여 줍니다. detail 객체에서 id는 접근 미리 보기 ID를 나타냅니다. status와 previousStatus는 접근 미리 보기 상태를 나타내는데, 이전 상태는 Creating이고 현재 상태는 Failed입니다. statusReason 필드는 잘못된 리소스 구성으로 접근 미리 보기가 실패했음을 나타내는 이유 코드를 제공합니다.
{
"account": "111122223333",
"detail": {
"accessPreviewId": "aaaabbbb-cccc-dddd-eeee-ffffaaaabbbb",
"configuredResources": [
"arn:aws:s3:::amzn-s3-demo-bucket"
],
"createdAt": "2020-02-20T00:00:00.00Z",
"previousStatus": "CREATING",
"region": "us-west-2",
"status": "FAILED",
"statusReason": {
"code": "INVALID_CONFIGURATION"
},
"version": "1.0"
},
"detail-type": "Access Preview State Change",
"id": "99998888-7777-6666-5555-444433332222",
"region": "us-west-2",
"resources": [
"arn:aws:access-analyzer:us-west-2:111122223333:analyzer/MyAnalyzer"
],
"source": "aws.access-analyzer",
"time": "2020-02-20T00:00:00.00Z",
"version": "0"
}
콘솔로 이벤트 규칙 만들기
다음 절차는 콘솔로 이벤트 규칙을 만드는 방법을 설명합니다.
- Amazon EventBridge 콘솔을 https://console.aws.amazon.com/events/에서 엽니다.
- 다음 값을 사용해 결과 이벤트나 접근 미리 보기 이벤트를 모니터링하는 EventBridge 규칙을 만듭니다.
- Rule type(규칙 유형) 에서 Rule with an event pattern(이벤트 패턴이 있는 규칙) 을 선택합니다.
- Event source(이벤트 소스) 에서 Other(기타) 를 선택합니다.
- Event pattern(이벤트 패턴) 에서 Custom patterns (JSON editor)(사용자 지정 패턴(JSON 편집기)) 을 선택하고, 다음 이벤트 패턴 예시 중 하나를 텍스트 영역에 붙여넣습니다.
{
"source": [
"aws.access-analyzer"
]
}
- 모든 IAM Access Analyzer 이벤트를 기반으로 규칙을 만들려면 다음 패턴 예시를 사용합니다.
{
"source": [
"aws.access-analyzer"
],
"detail-type": [
"Access Analyzer Finding",
"Internal Access Finding",
"Unused Access Finding for IAM entities"
]
}
- 외부 접근, 내부 접근 또는 미사용 접근 결과 이벤트를 기반으로 규칙을 만들려면 다음 패턴 예시를 사용합니다.
{
"source": [
"aws.access-analyzer"
],
"detail-type": [
"Access Analyzer Finding"
]
}
- 외부 접근 결과 이벤트만을 기반으로 규칙을 만들려면 다음 패턴 예시를 사용합니다.
{
"source": [
"aws.access-analyzer"
],
"detail-type": [
"Internal Access Finding"
]
}
- 내부 접근 결과 이벤트만을 기반으로 규칙을 만들려면 다음 패턴 예시를 사용합니다.
{
"source": [
"aws.access-analyzer"
],
"detail-type": [
"Unused Access Finding for IAM entities"
]
}
- 미사용 접근 결과 이벤트만을 기반으로 규칙을 만들려면 다음 패턴 예시를 사용합니다.
{
"source": [
"aws.access-analyzer"
],
"detail-type": [
"Access Preview State Change"
]
}
- 접근 미리 보기 이벤트를 기반으로 규칙을 만들려면 다음 패턴 예시를 사용합니다.
aws events put-rule --name TestRule --event-pattern "{\"source\":[\"aws.access-analyzer\"]}"
- Target types(대상 유형) 에서 AWS service(AWS 서비스) 를, Select a target(대상 선택) 에서 Amazon SNS 주제나 AWS Lambda 함수 같은 대상을 선택합니다. 규칙에 정의된 이벤트 패턴과 일치하는 이벤트를 수신하면 대상이 트리거됩니다.
이벤트에 반응하는 Amazon EventBridge 규칙 만들기에 대한 자세한 내용은 Amazon EventBridge 사용자 가이드를 참고하세요.
CLI로 이벤트 규칙 만들기
- AWS CLI로 Amazon EventBridge의 규칙을 만들려면 다음을 사용합니다. 규칙 이름
TestRule을 자신의 규칙 이름으로 바꾸세요.
aws events put-rule --name TestRule --event-pattern "{\"source\":[\"aws.access-analyzer\"],\"detail-type\":[\"Access Analyzer Finding\"],\"detail\":{\"status\":[\"ACTIVE\"]}}"
- 특정 속성을 가진 결과 같은 생성된 결과의 일부분에 대해서만 대상 작업을 트리거하도록 규칙을 커스터마이징할 수 있습니다. 다음 예시는 상태가
Active인 결과에 대해서만 대상 작업을 트리거하는 규칙을 만드는 방법을 보여 줍니다.
aws events put-rule --name TestRule --event-pattern "{\"source\":[\"aws.access-analyzer\"],\"detail-type\":[\"Access Preview State Change\"],\"detail\":{\"status\":[\"COMPLETED\"]}}"
다음 예시는 상태가 Creating에서 Completed로 바뀌는 접근 미리 보기에 대해서만 대상 작업을 트리거하는 규칙을 만드는 방법을 보여 줍니다.
aws events put-targets --rule TestRule --targets Id=1,Arn=arn:aws:lambda:us-east-1:111122223333:function:MyFunction
- 만든 규칙의 대상으로 Lambda 함수를 정의하려면 다음 예시 명령을 사용합니다. 리전과 ARN의 함수 이름을 환경에 맞게 바꾸세요.
aws lambda add-permission --function-name MyFunction --statement-id 1 --action 'lambda:InvokeFunction' --principal events.amazonaws.com
- 규칙 대상을 호출하는 데 필요한 권한을 추가합니다. 다음 예시는 앞선 예시를 따라 Lambda 함수에 권한을 부여하는 방법을 보여 줍니다.