

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# Amazon EBS용 Amazon EventBridge 이벤트
Amazon EventBridge

Amazon EBS는 볼륨 및 스냅샷에 대해 수행된 작업의 이벤트를 Amazon EventBridge로 전송합니다. EventBridge에서는 이러한 이벤트에 대한 응답으로 프로그래밍 작업을 트리거하는 규칙을 설정할 수 있습니다. 예를 들어 스냅샷의 빠른 스냅샷 복원이 활성화된 경우 이메일로 알림을 보내는 규칙을 만들 수 있습니다.

EventBridge의 이벤트는 JSON 객체로 표현됩니다. 이 이벤트에 고유한 필드는 JSON 객체의 "세부 정보" 섹션에 포함되어 있습니다. "이벤트" 필드에는 이벤트 이름이 포함됩니다. "결과" 필드에는 이벤트를 트리거한 작업의 완료 상태가 포함됩니다. 자세한 내용은 Amazon EventBridge 사용 설명서의 [Amazon EventBridge 이벤트 패턴](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html)**을 참조하세요.

자세한 내용은 *Amazon EventBridge User Guide(Amazon EventBridge 사용 설명서)*의 [What Is Amazon EventBridge?(Amazon EventBridge란?)](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-what-is.html)를 참조하세요.

**Topics**
+ [

## EBS 볼륨 이벤트
](#volume-events)
+ [

## EBS 볼륨 초기화 이벤트
](#volume-initialization-events)
+ [

## EBS 볼륨 수정 이벤트
](#volume-modification-events)
+ [

## EBS 스냅샷 이벤트
](#snapshot-events)
+ [

## EBS 스냅샷 아카이브 이벤트
](#snapshot-archive-events)
+ [

## EBS 빠른 스냅샷 복원 이벤트
](#fast-snapshot-restore-events)
+ [

# AWS Lambda 를 사용하여 EventBridge 이벤트 처리
](using_lambda.md)

## EBS 볼륨 이벤트


Amazon EBS는 다음과 같은 볼륨 이벤트가 발생하는 경우 EventBridge에 이벤트를 보냅니다.

**Topics**
+ [createVolume](#create-volume)
+ [deleteVolume](#delete-volume)
+ [attachVolume](#attach-fail-key)
+ [detachVolume](#detach-volume)

### 볼륨 생성(createVolume)
createVolume

볼륨 생성 작업이 완료되면 `createVolume` 이벤트가 AWS 계정으로 전송됩니다. 그러나 저장, 로깅, 아카이빙은 되지 않습니다. 이 이벤트에서 `available` 또는 `failed` 결과가 발생할 수 있습니다. 아래 예제와 같이 잘못된가 AWS KMS key 제공되면 생성이 실패합니다.

**이벤트 데이터**  
아래 목록에 성공적인 `createVolume` 이벤트에 대해 EBS가 발생시키는 JSON 객체의 예를 열거했습니다.

```
{
   "version": "0",
   "id": "01234567-0123-0123-0123-012345678901",
   "detail-type": "EBS Volume Notification",
   "source": "aws.ec2",
   "account": "012345678901",
   "time": "yyyy-mm-ddThh:mm:ssZ",
   "region": "us-east-1",
   "resources": [
      "arn:aws:ec2:us-east-1:012345678901:volume/vol-01234567"
   ],
   "detail": {
      "result": "available",
      "cause": "",
      "event": "createVolume",
      "request-id": "01234567-0123-0123-0123-0123456789ab"
   }
}
```

아래 목록에 `createVolume` 이벤트 실패 이후 EBS가 발생시키는 JSON 객체의 예를 열거했습니다. 실패의 원인은 비활성화된 KMS 키였습니다.

```
{
  "version": "0",
  "id": "01234567-0123-0123-0123-0123456789ab",
  "detail-type": "EBS Volume Notification",
  "source": "aws.ec2",
  "account": "012345678901",
  "time": "yyyy-mm-ddThh:mm:ssZ",
  "region": "sa-east-1",
  "resources": [
    "arn:aws:ec2:sa-east-1:0123456789ab:volume/vol-01234567",
  ],
  "detail": {
    "event": "createVolume",
    "result": "failed",
    "cause": "arn:aws:kms:sa-east-1:0123456789ab:key/01234567-0123-0123-0123-0123456789ab is disabled.",
    "request-id": "01234567-0123-0123-0123-0123456789ab",
  }
}
```

아래에 `createVolume` 이벤트 실패 이후 EBS가 발생시키는 JSON 객체의 예를 제시했습니다. 실패의 원인은 보류 중인 KMS 키 가져오기였습니다.

```
{  
  "version": "0",  
  "id": "01234567-0123-0123-0123-0123456789ab",  
  "detail-type": "EBS Volume Notification",  
  "source": "aws.ec2",  
  "account": "012345678901",  
  "time": "yyyy-mm-ddThh:mm:ssZ",  
  "region": "sa-east-1",  
  "resources": [    
    "arn:aws:ec2:sa-east-1:0123456789ab:volume/vol-01234567",  
  ],  
  "detail": {    
    "event": "createVolume",    
    "result": "failed",    
    "cause": "arn:aws:kms:sa-east-1:0123456789ab:key/01234567-0123-0123-0123-0123456789ab is pending import.",    
    "request-id": "01234567-0123-0123-0123-0123456789ab",  
  }
}
```

### 볼륨 삭제(deleteVolume)
deleteVolume

볼륨 삭제 작업이 완료되면 `deleteVolume` 이벤트가 AWS 계정으로 전송됩니다. 그러나 저장, 로깅, 아카이빙은 되지 않습니다. 이 이벤트에 `deleted` 결과가 있습니다. 삭제가 완료되지 않으면 이벤트가 전송되지 않습니다.

**이벤트 데이터**  
아래 목록에 성공적인 `deleteVolume` 이벤트에 대해 EBS가 발생시키는 JSON 객체의 예를 열거했습니다.

```
{
   "version": "0",
   "id": "01234567-0123-0123-0123-012345678901",
   "detail-type": "EBS Volume Notification",
   "source": "aws.ec2",
   "account": "012345678901",
   "time": "yyyy-mm-ddThh:mm:ssZ",
   "region": "us-east-1",
   "resources": [
      "arn:aws:ec2:us-east-1:012345678901:volume/vol-01234567"
   ],
   "detail": {
      "result": "deleted",
      "cause": "",
      "event": "deleteVolume",
      "request-id": "01234567-0123-0123-0123-0123456789ab"
   }
}
```

### 볼륨 연결 또는 다시 연결(attachVolume, reattachVolume)
attachVolume

볼륨이 인스턴스에 연결되거나 재연결될 때 `attachVolume` 또는 `reattachVolume` 이벤트가 AWS 계정으로 전송됩니다. 그러나 저장, 로깅, 아카이빙은 되지 않습니다. KMS 키를 사용하여 EBS 볼륨을 암호화할 경우 KMS 키이(가) 무효해지면, EBS는 해당 KMS 키이(가) 나중에 인스턴스에 연결하거나 다시 연결하는 데 사용될 경우 이벤트를 발송합니다(아래 예 참조).

**이벤트 데이터**  
아래 목록에 `attachVolume` 이벤트 실패 이후 EBS가 발생시키는 JSON 객체의 예를 열거했습니다. 실패의 원인은 보류 중인 KMS 키 삭제였습니다.

**참고**  
AWS 는 정기 서버 유지 관리 후 볼륨에 재연결을 시도할 수 있습니다.

```
{
  "version": "0",    
  "id": "01234567-0123-0123-0123-0123456789ab",
  "detail-type": "EBS Volume Notification",
  "source": "aws.ec2",
  "account": "012345678901",
  "time": "yyyy-mm-ddThh:mm:ssZ",
  "region": "us-east-1",
  "resources": [
  "arn:aws:ec2:us-east-1:0123456789ab:volume/vol-01234567",
  "arn:aws:kms:us-east-1:0123456789ab:key/01234567-0123-0123-0123-0123456789ab"
  ],
  "detail": {
    "event": "attachVolume",
    "result": "failed",
    "cause": "arn:aws:kms:us-east-1:0123456789ab:key/01234567-0123-0123-0123-0123456789ab is pending deletion.",
    "request-id": ""
  }
}
```

아래 목록에 `reattachVolume` 이벤트 실패 이후 EBS가 발생시키는 JSON 객체의 예를 열거했습니다. 실패의 원인은 보류 중인 KMS 키 삭제였습니다.

```
{
  "version": "0",    
  "id": "01234567-0123-0123-0123-0123456789ab",
  "detail-type": "EBS Volume Notification",
  "source": "aws.ec2",
  "account": "012345678901",
  "time": "yyyy-mm-ddThh:mm:ssZ",
  "region": "us-east-1",
  "resources": [
  "arn:aws:ec2:us-east-1:0123456789ab:volume/vol-01234567",
  "arn:aws:kms:us-east-1:0123456789ab:key/01234567-0123-0123-0123-0123456789ab"
  ],
  "detail": {
    "event": "reattachVolume",
    "result": "failed",
    "cause": "arn:aws:kms:us-east-1:0123456789ab:key/01234567-0123-0123-0123-0123456789ab is pending deletion.",
    "request-id": ""
  }
}
```

### 볼륨 분리(detachVolume)
detachVolume

Amazon EC2 인스턴스에서 볼륨이 분리되면 `detachVolume` 이벤트가 AWS 계정으로 전송됩니다.

**이벤트 데이터**  
다음은 성공적인 `detachVolume` 이벤트의 예입니다.

```
{
  "version":"0",
  "id":"2ec37298-1234-e436-70fc-c96b1example",
  "detail-type":"AWS API Call via CloudTrail",
  "source":"aws.ec2",
  "account":"123456789012",
  "time":"2024-03-18T16:35:52Z",
  "region":"us-east-1",
  "resources":[],
  "detail":
  {
    "eventVersion":"1.09",
    "userIdentity":
    {
      "type":"IAMUser",
      "principalId":"AIDAJT12345SQ2EXAMPLE",
      "arn":"arn:aws:iam::123456789012:user/administrator",
      "accountId":"123456789012",
      "accessKeyId":"AKIAJ67890A6EXAMPLE",
      "userName":"administrator"
    },
    "eventTime":"2024-03-18T16:35:52Z",
    "eventSource":"ec2.amazonaws.com",
    "eventName":"DetachVolume",
    "awsRegion":"us-east-1",
    "sourceIPAddress":"12.12.123.12",
    "userAgent":"aws-cli/2.7.12 Python/3.9.11 Windows/10 exe/AMD64 prompt/off command/ec2.detach-volume",
    "requestParameters":
    {
      "volumeId":"vol-072577c46bexample",
      "force":false
    },
    "responseElements":
    {
      "requestId":"1234513a-6292-49ea-83f8-85e95example",
      "volumeId":"vol-072577c46bexample",
      "instanceId":"i-0217f7eb3dexample",
      "device":"/dev/sdb",
      "status":"detaching",
      "attachTime":1710776815000
    },
    "requestID":"1234513a-6292-49ea-83f8-85e95example",
    "eventID":"1234551d-a15a-43eb-9e69-c983aexample",
    "readOnly":false,
    "eventType":"AwsApiCall",
    "managementEvent":true,
    "recipientAccountId":"123456789012",
    "eventCategory":"Management",
    "tlsDetails":
    {
      "tlsVersion":"TLSv1.3",
      "cipherSuite":"TLS_AES_128_GCM_SHA256",
      "clientProvidedHostHeader":"ec2.us-east-1.amazonaws.com"
    }
  }
}
```

## EBS 볼륨 초기화 이벤트


스냅샷에서 Amazon EBS 볼륨을 생성하고 볼륨 초기화에 기본 볼륨 초기화 속도 또는 Amazon EBS 프로비저닝 속도를 사용하면 볼륨 초기화가 완료된 후 5분 이내에 `initializeVolume` 이벤트가 AWS 계정으로 전송됩니다. 자세한 내용은 [볼륨 초기화에 Amazon EBS 프로비저닝 속도 사용](initalize-volume.md#volume-initialization-rate) 단원을 참조하십시오.

빠른 스냅샷 복원을 사용하여 생성된 볼륨에 대해서는 이벤트가 전송되지 **않습니다**.

**중요**  
`completionTime`은 이벤트를 생성한 시간을 반영합니다. 이벤트는 초기화가 완료된 후 5분 이내에 생성되므로 `completionTime`은 초기화가 완료된 후 최대 5분이 될 수 있습니다.

다음은 이벤트 예제입니다.

```
{
   "version": "0",
   "id": "01234567-0123-0123-0123-012345678901",
   "detail-type": "EBS Volume Notification",
   "source": "aws.ec2",
   "account": "012345678901",
   "time": "yyyy-mm-ddThh:mm:ssZ",
   "region": "us-east-1",
   "resources": [
      "arn:aws:ec2:us-east-1:012345678901:volume/vol-01234567890abcdef"
   ],
   "detail": {
      "event": " initializeVolume",
      "result": "succeeded",
      "completionTime": "yyyy-mm-ddThh:mm:ssZ",
      "request-id": "01234567-0123-0123-0123-0123456789ab"
   }
}
```

## EBS 볼륨 수정 이벤트


Amazon EBS는 볼륨이 수정될 때 EventBridge에 `modifyVolume` 이벤트를 보냅니다. 그러나 저장, 로깅, 아카이빙은 되지 않습니다.

```
{
   "version": "0",
   "id": "01234567-0123-0123-0123-012345678901",
   "detail-type": "EBS Volume Notification",
   "source": "aws.ec2",
   "account": "012345678901",
   "time": "yyyy-mm-ddThh:mm:ssZ",
   "region": "us-east-1",
   "resources": [
      "arn:aws:ec2:us-east-1:012345678901:volume/vol-03a55cf56513fa1b6"
   ],
   "detail": {
      "result": "optimizing",
      "cause": "",
      "event": "modifyVolume",
      "request-id": "01234567-0123-0123-0123-0123456789ab"
   }
}
```

## EBS 스냅샷 이벤트


Amazon EBS는 다음과 같은 볼륨 이벤트가 발생하는 경우 EventBridge에 이벤트를 보냅니다.

**Topics**
+ [createSnapshot](#create-snapshot-complete)
+ [createSnapshots](#create-snapshots-complete)
+ [copySnapshot](#copy-snapshot-complete)
+ [shareSnapshot](#snapshot-shared)

### 스냅샷 생성(createSnapshot)
createSnapshot

스냅샷 생성 작업이 완료되면 `createSnapshot` 이벤트가 AWS 계정으로 전송됩니다. 그러나 저장, 로깅, 아카이빙은 되지 않습니다. 이 이벤트에서 `succeeded` 또는 `failed` 결과가 발생할 수 있습니다.

**이벤트 데이터**  
아래 목록에 성공적인 `createSnapshot` 이벤트에 대해 EBS가 발생시키는 JSON 객체의 예를 열거했습니다. `detail` 섹션에서 `source` 필드에는 소스 볼륨의 ARN이 들어 있습니다. `startTime` 및 `endTime` 필드는 스냅샷 생성이 시작된 시점과 완료된 시점을 나타냅니다.

```
{
  "version": "0",
  "id": "01234567-0123-0123-0123-012345678901",
  "detail-type": "EBS Snapshot Notification",
  "source": "aws.ec2",
  "account": "012345678901",
  "time": "yyyy-mm-ddThh:mm:ssZ",
  "region": "us-east-1",
  "resources": [
     "arn:aws:ec2::us-west-2:snapshot/snap-01234567"
  ],
  "detail": {
    "event": "createSnapshot",
    "result": "succeeded",
    "cause": "",
    "request-id": "",
    "snapshot_id": "arn:aws:ec2::us-west-2:snapshot/snap-01234567",
    "source": "arn:aws:ec2::us-west-2:volume/vol-01234567",
    "startTime": "yyyy-mm-ddThh:mm:ssZ",
    "endTime": "yyyy-mm-ddThh:mm:ssZ"  }
}
```

### 스냅샷 생성(createSnapshots)
createSnapshots

다중 볼륨 스냅샷을 생성하는 작업이 완료되면 `createSnapshots` 이벤트가 AWS 계정으로 전송됩니다. 이 이벤트에서 `succeeded` 또는 `failed` 결과가 발생할 수 있습니다.

**이벤트 데이터**  
아래 목록에 성공적인 `createSnapshots` 이벤트에 대해 EBS가 발생시키는 JSON 객체의 예를 열거했습니다. `detail` 섹션의 `source` 필드에는 다중 볼륨 스냅샷 세트의 소스 볼륨 ARN이 포함되어 있습니다. `startTime` 및 `endTime` 필드는 스냅샷 생성이 시작된 시점과 완료된 시점을 나타냅니다.

```
{
  "version": "0",
  "id": "01234567-0123-0123-0123-012345678901",
  "detail-type": "EBS Multi-Volume Snapshots Completion Status",
  "source": "aws.ec2",
  "account": "012345678901",
  "time": "yyyy-mm-ddThh:mm:ssZ",
  "region": "us-east-1",
  "resources": [
    "arn:aws:ec2::us-east-1:snapshot/snap-01234567",
    "arn:aws:ec2::us-east-1:snapshot/snap-012345678"
  ],
  "detail": {
    "event": "createSnapshots",
    "result": "succeeded",
    "cause": "",
    "request-id": "",
    "startTime": "yyyy-mm-ddThh:mm:ssZ",
    "endTime": "yyyy-mm-ddThh:mm:ssZ",
    "snapshots": [
      {
        "snapshot_id": "arn:aws:ec2::us-east-1:snapshot/snap-01234567",
        "source": "arn:aws:ec2::us-east-1:volume/vol-01234567",
        "status": "completed"
      },
      {
        "snapshot_id": "arn:aws:ec2::us-east-1:snapshot/snap-012345678",
        "source": "arn:aws:ec2::us-east-1:volume/vol-012345678",
        "status": "completed"
      }
    ]
  }
}
```

아래 목록에 `createSnapshots` 이벤트 실패 이후 EBS가 발생시키는 JSON 객체의 예를 열거했습니다. 실패 원인은 다중 볼륨 스냅샷 세트에 대한 하나 이상의 스냅샷이 완료되지 못했기 때문입니다. `snapshot_id`의 값은 실패한 스냅샷의 ARN입니다. `startTime` 및 `endTime`은 스냅샷 생성 작업이 시작 및 종료된 시기를 나타냅니다.

```
{
  "version": "0",
  "id": "01234567-0123-0123-0123-012345678901",
  "detail-type": "EBS Multi-Volume Snapshots Completion Status",
  "source": "aws.ec2",
  "account": "012345678901",
  "time": "yyyy-mm-ddThh:mm:ssZ",
  "region": "us-east-1",
  "resources": [
    "arn:aws:ec2::us-east-1:snapshot/snap-01234567",
    "arn:aws:ec2::us-east-1:snapshot/snap-012345678"
  ],
"detail": {
    "event": "createSnapshots",
    "result": "failed",
    "cause": "Snapshot snap-01234567 is in status error",
   "request-id": "",
    "startTime": "yyyy-mm-ddThh:mm:ssZ",
    "endTime": "yyyy-mm-ddThh:mm:ssZ",
    "snapshots": [
      {
        "snapshot_id": "arn:aws:ec2::us-east-1:snapshot/snap-01234567",
        "source": "arn:aws:ec2::us-east-1:volume/vol-01234567",
        "status": "error"
      },
      {
        "snapshot_id": "arn:aws:ec2::us-east-1:snapshot/snap-012345678",
        "source": "arn:aws:ec2::us-east-1:volume/vol-012345678",
        "status": "error"
      }
    ]
  }
}
```

### 스냅샷 복사(copySnapshot)
copySnapshot

스냅샷 복사 작업이 완료되면 `copySnapshot` 이벤트가 AWS 계정으로 전송됩니다. 그러나 저장, 로깅, 아카이빙은 되지 않습니다. 이 이벤트에서 `succeeded` 또는 `failed` 결과가 발생할 수 있습니다.

`detail` 섹션에서 `source`는 소스 스냅샷의 ARN이고 `snapshot_id`는 스냅샷 복사본의 ARN입니다. `startTime` 및 `endTime`은 복사 작업이 시작되고 종료된 시기를 나타냅니다. `incremental`은 스냅샷 복사가 증분 스냅샷(`true`)인지 아니면 전체 스냅샷(`false`)인지를 나타냅니다. `transferType`은 스냅샷 복사 작업이 표준 복사 작업인지 아니면 시간 기반 복사 작업인지를 나타냅니다. 자세한 내용은 [Amazon EBS 스냅샷 및 EBS 지원 AMI의 시간 기반 복사본](time-based-copies.md) 단원을 참조하십시오.

리전 간에 스냅샷을 복사하는 경우 대상 리전에서 이벤트가 발생합니다.

**시나리오 1: 표준 스냅샷 복사 작업이 완료됨**  
다음은 표준 스냅샷 복사 작업이 성공적으로 완료되었을 때 계정으로 전송되는 이벤트의 예제입니다. `transferType`은 `standard`임을 참고하세요.

```
{
  "version": "0",
  "id": "01234567-0123-0123-0123-012345678901",
  "detail-type": "EBS Snapshot Notification",
  "source": "aws.ec2",
  "account": "123456789012",
  "time": "yyyy-mm-ddThh:mm:ssZ",
  "region": "us-east-1",
  "resources": [
    "arn:aws:ec2::us-west-2:snapshot/snap-01234567"
  ],
  "detail": {
    "event": "copySnapshot",
    "result": "succeeded",
    "cause": "",
    "request-id": "",
    "snapshot_id": "arn:aws:ec2::us-west-2:snapshot/snap-01234567",
    "source": "arn:aws:ec2::eu-west-1:snapshot/snap-76543210",
    "startTime": "yyyy-mm-ddThh:mm:ssZ",
    "endTime": "yyyy-mm-ddThh:mm:ssZ",
    "incremental": "true",
    "transferType": "standard"
  }
}
```

**시나리오 2: 시간 기반 스냅샷 복사 작업이 완료 기간 내에 완료됨**  
다음은 시간 기반 스냅샷 복사 작업이 완료 기간 내에 완료될 때 계정으로 전송되는 이벤트의 예제입니다. `transferType`은 시간 기반 스냅샷 복사 작업임을 나타내는 `time-based`입니다. `completionDurationStartTime`은 완료 기간이 시작된 시점을 나타냅니다.

```
{
  "version": "0",
  "id": "01234567-0123-0123-0123-012345678901",
  "detail-type": "EBS Snapshot Notification",
  "source": "aws.ec2",
  "account": "123456789012",
  "time": "yyyy-mm-ddThh:mm:ssZ",
  "region": "us-east-1",
  "resources": [
    "arn:aws:ec2::us-west-2:snapshot/snap-01234567"
  ],
  "detail": {
    "event": "copySnapshot",
    "result": "succeeded",
    "cause": "",
    "request-id": "",
    "startTime": "yyyy-mm-ddThh:mm:ssZ",
    "endTime": "yyyy-mm-ddThh:mm:ssZ",
    "snapshot_id": "arn:aws:ec2::us-west-2:snapshot/snap-01234567",
    "source": "arn:aws:ec2::eu-west-1:snapshot/snap-76543210",
    "incremental": "true", 
    "completionDurationStartTime":"2024-11-16T06:27:33.816Z",
    "transferType": "time-based"
  }
}
```

**시나리오 3: 시간 기반 스냅샷 복사 작업이 완료되었지만 요청된 완료 기간을 놓침**  
시간 기반 스냅샷 복사 작업이 완료되었지만 요청된 완료 기간을 충족하지 못하면 CloudWatch에서 두 개의 이벤트를 계정에 전송합니다. 다음은 이러한 이벤트의 예제입니다.
+ 첫 번째 이벤트는 복사 작업이 아직 진행 중인 경우에도 완료 기간을 놓치는 즉시 계정으로 전송됩니다. 이 이벤트의 경우 `detail-type`은 `EBS Copy Snapshot Missed Completion Duration`이며 `missedCompletionDurationCause`는 해당 이유를 제공합니다.

  ```
  {
   "version":"0",
   "id":"fd90eb95-0938-e02c-cf55-b81363b8ac12",
   "detail-type":"EBS Copy Snapshot Missed Completion Duration",
   "source":"aws.ec2",
   "account":"123456789012",
   "time":"2024-11-19T18:17:08Z",
   "region":"us-east-1",
   "resources": ["arn:aws:ec2:us-east-1:123456789012:snapshot/snap-01234567890abcedf"],
   "detail":{
     "event":"copySnapshot",
     "missedCompletionDurationCause":"Snapshot copy was not able to meet the specified completion duration because your snapshot copy operation throughput quota was exceeded.",
     "snapshot_id":"arn:aws:ec2:us-east-1:123456789012:snapshot/snap-01234567890abcedf",
     "source":"arn:aws:ec2:us-east-1:123456789012:snapshot/snap-00987654321fedcba",
     "startTime": "Sun Nov 24 22:32:55 UTC 2024",
     "transferType": "time-based"
     }
  }
  ```
+ 두 번째 이벤트는 스냅샷이 완료된 후에만 계정에 전송됩니다. 이벤트는 해당 이유를 제공하는 `missedCompletionDurationCause`를 포함합니다.

  ```
  {
    "version": "0",
    "id": "01234567-0123-0123-0123-012345678901",
    "detail-type": "EBS Snapshot Notification",
    "source": "aws.ec2",
    "account": "123456789012",
    "time": "yyyy-mm-ddThh:mm:ssZ",
    "region": "us-east-1",
    "resources": [
      "arn:aws:ec2::us-west-2:snapshot/snap-01234567"
    ],
    "detail": {
      "event": "copySnapshot",
      "result": "succeeded",
      "cause": "",
      "request-id": "",
      "startTime": "yyyy-mm-ddThh:mm:ssZ",
      "endTime": "yyyy-mm-ddThh:mm:ssZ",
      "snapshot_id": "arn:aws:ec2::us-west-2:snapshot/snap-01234567",
      "source": "arn:aws:ec2::eu-west-1:snapshot/snap-76543210",
      "incremental": "true", 
      "completionDurationStartTime":"2024-11-16T06:27:33.816Z",
      "missedCompletionDurationCause":"Snapshot copy was not able to meet the specified completion duration because your snapshot copy operation throughput quota was exceeded.",
      "transferType": "time-based"
    }
  }
  ```

**시나리오 4: 스냅샷 복사 작업이 실패함**  
다음은 스냅샷 복사 작업이 실패할 때 계정으로 전송되는 이벤트의 예제입니다. `result`는 작업이 실패했음을 나타내는 `failed`입니다.

```
{
  "version": "0",
  "id": "01234567-0123-0123-0123-012345678901",
  "detail-type": "EBS Snapshot Notification",
  "source": "aws.ec2",
  "account": "123456789012",
  "time": "yyyy-mm-ddThh:mm:ssZ",
  "region": "us-east-1",
  "resources": [
    "arn:aws:ec2::us-west-2:snapshot/snap-01234567"
  ],
  "detail": {
    "event": "copySnapshot",
    "result": "failed",
    "cause": "Source snapshot ID is not valid",
    "request-id": "",
    "snapshot_id": "arn:aws:ec2::us-west-2:snapshot/snap-01234567",
    "source": "arn:aws:ec2::eu-west-1:snapshot/snap-76543210",
    "startTime": "yyyy-mm-ddThh:mm:ssZ",
    "endTime": "yyyy-mm-ddThh:mm:ssZ"
  }
}
```

### 스냅샷 공유(shareSnapshot)
shareSnapshot

다른 AWS 계정이 스냅샷을 공유하면 `shareSnapshot` 이벤트가 계정으로 전송됩니다. 그러나 저장, 로깅, 아카이빙은 되지 않습니다. 결과는 항상 `succeeded`입니다.

**이벤트 데이터**  
아래에 `shareSnapshot` 이벤트 완료 이후 EBS가 발생시키는 JSON 객체의 예를 열거했습니다. `detail` 섹션에서의 값은 스냅샷을 공유한 사용자의 AWS 계정 번호`source`입니다. `startTime` 및는 공유 스냅샷 작업이 시작되고 종료된 시기를 `endTime` 나타냅니다. `shareSnapshot` 이벤트는 프라이빗 스냅샷이 다른 사용자와 공유될 때만 발생합니다. 퍼블릭 스냅샷 공유는 이벤트를 트리거하지 않습니다.

```
{
  "version": "0",
  "id": "01234567-01234-0123-0123-012345678901",
  "detail-type": "EBS Snapshot Notification",
  "source": "aws.ec2",
  "account": "012345678901",
  "time": "yyyy-mm-ddThh:mm:ssZ",
  "region": "us-east-1",
  "resources": [
    "arn:aws:ec2::us-west-2:snapshot/snap-01234567"
  ],
  "detail": {
    "event": "shareSnapshot",
    "result": "succeeded",
    "cause": "",
    "request-id": "",
    "snapshot_id": "arn:aws:ec2::us-west-2:snapshot/snap-01234567",
    "source": 012345678901,
    "startTime": "yyyy-mm-ddThh:mm:ssZ",
    "endTime": "yyyy-mm-ddThh:mm:ssZ"
  }
}
```

## EBS 스냅샷 아카이브 이벤트


Amazon EBS는 스냅샷 아카이빙 작업과 관련된 이벤트를 내보냅니다. 자세한 내용을 알아보려면 [CloudWatch Events를 사용하여 Amazon EBS 스냅샷 아카이빙 모니터링](monitor-snapshot-archiving.md) 섹션을 참조하세요.

## EBS 빠른 스냅샷 복원 이벤트


Amazon EBS는 스냅샷에 대한 빠른 스냅샷 복원 상태가 변경되면 이벤트를 EventBridge로 보냅니다. 이벤트는 최선의 작업을 기반으로 발생됩니다.

다음은 이 이벤트의 예제 데이터입니다.

```
{
   "version": "0",
   "id": "01234567-0123-0123-0123-012345678901",
   "detail-type": "EBS Fast Snapshot Restore State-change Notification",
   "source": "aws.ec2",
   "account": "123456789012",
   "time": "yyyy-mm-ddThh:mm:ssZ",
   "region": "us-east-1",
   "resources": [
      "arn:aws:ec2:us-east-1::snapshot/snap-03a55cf56513fa1b6"
   ],
   "detail": {
      "snapshot-id": "snap-1234567890abcdef0",
      "state": "optimizing",
      "zone": "us-east-1a",
      "message": "Client.UserInitiated - Lifecycle state transition",
   }
}
```

가능한 `state` 값은 `enabling`, `optimizing`, `enabled`, `disabling`, `disabled`입니다.

`message`에 가능한 값은 다음과 같습니다.

`Client.InvalidSnapshot.InvalidState - The requested snapshot transitioned to an invalid state (Error)`  
빠른 스냅샷 복원을 요청하는 요청이 실패하고 상태가 `disabling` 또는 `disabled`로 전환되었습니다. 빠른 스냅샷 복원은 이 스냅 샷에 대해 활성화할 수 없습니다.

`Client.UserInitiated`  
상태가 `enabling` 또는 `disabling`으로 전환되었습니다.

`Client.UserInitiated - Lifecycle state transition`  
상태가 `optimizing`, `enabled` 또는 `disabled`로 전환되었습니다.

`Server.InsufficientCapacity - There was insufficient capacity available to satisfy the request`  
불충분한 용량으로 인해 빠른 스냅샷 복원을 요청하는 요청이 실패하고 상태가 `disabling` 또는 `disabled`로 전환되었습니다. 잠시 기다렸다가 다시 시도하세요.

`Server.InternalError - An internal error caused the operation to fail`  
내부 오류로 인해 빠른 스냅샷 복원을 요청하는 요청이 실패하고 상태가 `disabling` 또는 `disabled`로 전환되었습니다. 잠시 기다렸다가 다시 시도하세요.

`Client.InvalidSnapshot.InvalidState - The requested snapshot was deleted or access permissions were revoked`  
스냅샷이 스냅샷 소유자에 의해 삭제되거나 공유 해제되었으므로 스냅샷에 대한 빠른 스냅샷 복원 상태가 `disabling` 또는 `disabled`로 전환되었습니다. 삭제되었거나 더 이상 본인에게 공유되지 않은 스냅샷에 대해서는 빠른 스냅샷 복원을 활성화할 수 없습니다.

# AWS Lambda 를 사용하여 EventBridge 이벤트 처리


Amazon EBS와 Amazon EventBridge를 사용하여 데이터 백업 워크플로를 자동화할 수 있습니다. 이를 위해서는 IAM 정책, 이벤트를 처리하는 AWS Lambda 함수, 수신 이벤트와 일치하고 이를 Lambda 함수로 라우팅하는 EventBridge 규칙을 생성해야 합니다.

다음 절차에서는 재해 복구를 위해 `createSnapshot` 이벤트를 사용하여 완료된 스냅샷을 다른 리전으로 자동으로 복사합니다.

**완료된 스냅샷을 다른 리전으로 복사하려면**

1. 다음 예에 표시된 것과 같이 `CopySnapshot` 작업을 사용하고 EventBridge 로그에 쓸 수 있는 권한을 제공하려면 IAM 정책을 생성합니다. EventBridge 이벤트를 처리할 사용자에게 정책을 할당합니다.

------
#### [ JSON ]

****  

   ```
   {
     "Version":"2012-10-17",		 	 	 
     "Statement": [
       {
         "Effect": "Allow",
         "Action": [
           "logs:CreateLogGroup",
           "logs:CreateLogStream",
           "logs:PutLogEvents"
         ],
         "Resource": "arn:aws:logs:*:*:*"
       },
       {
         "Effect": "Allow",
         "Action": [
           "ec2:CopySnapshot"
         ],
         "Resource": "*"
       }
     ]
   }
   ```

------

1. EventBridge 콘솔에서 사용할 수 있는 Lambda 함수를 정의합니다. 아래 Node.js로 작성된 샘플 Lambda 함수는 일치하는 `createSnapshot` 이벤트를 Amazon EBS가 발생시킬 때 EventBridge에 의해 호출됩니다. 이는 스냅샷이 완료되었음을 의미합니다. 호출되면 함수가 `us-east-2`에서 `us-east-1`로 스냅샷을 복사합니다.

   ```
   // Sample Lambda function to copy an EBS snapshot to a different Region
    
   var AWS = require('aws-sdk');
   var ec2 = new AWS.EC2();
    
   // define variables
   var destinationRegion = 'us-east-1';
   var sourceRegion = 'us-east-2';
   console.log ('Loading function');
    
   //main function
   exports.handler = (event, context, callback) => {
    
       // Get the EBS snapshot ID from the event details
       var snapshotArn = event.detail.snapshot_id.split('/');
       const snapshotId = snapshotArn[1];
       const description = `Snapshot copy from ${snapshotId} in ${sourceRegion}.`;
       console.log ("snapshotId:", snapshotId);
   
       // Load EC2 class and update the configuration to use destination Region to initiate the snapshot.
       AWS.config.update({region: destinationRegion});
       var ec2 = new AWS.EC2();
   
       // Prepare variables for ec2.modifySnapshotAttribute call
       const copySnapshotParams = {
           Description: description,
           DestinationRegion: destinationRegion,
           SourceRegion: sourceRegion,
           SourceSnapshotId: snapshotId
       };
    
       // Execute the copy snapshot and log any errors
       ec2.copySnapshot(copySnapshotParams, (err, data) => {
           if (err) {
               const errorMessage = `Error copying snapshot ${snapshotId} to Region ${destinationRegion}.`;
               console.log(errorMessage);
               console.log(err);
               callback(errorMessage);
           } else {
               const successMessage = `Successfully started copy of snapshot ${snapshotId} to Region ${destinationRegion}.`;
               console.log(successMessage);
               console.log(data);
               callback(null, successMessage);
           }
       });
   };
   ```

   Lambda 함수를 EventBridge 콘솔에서 사용하도록 보장하려면 EventBridge 이벤트가 발생하는 리전에서 생성합니다. 자세한 내용은 [ 개발자 안내서AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/)를 참조하세요.

1. Amazon EventBridge 콘솔([https://console.aws.amazon.com/events/](https://console.aws.amazon.com/events/))을 엽니다.

1. 탐색 창에서 **규칙(Rules)**을 선택한 후 **규칙 생성(Create rule)**을 선택합니다.

1. **Step 1: Define rule detail**(1단계: 규칙 세부 정보 정의)에 대해 다음을 수행합니다.

   1. **Name**(이름)과 **Description**(설명)을 입력합니다.

   1. **Event bus**(이벤트 버스)의 경우 **default**(기본값)를 유지합니다.

   1. **Enable the rule on the selected event bus**(선택한 이벤트 버스에 대해 규칙 활성화)가 설정되었는지 확인합니다.

   1. **Event type**(이벤트 유형)에서 **Rule with an event pattern**(이벤트 패턴이 있는 규칙)을 선택합니다.

   1. **다음**을 선택합니다.

1. **Step 2: Build event pattern**(2단계: 이벤트 패턴 빌드)에서 다음을 수행합니다.

   1. **Event source**(이벤트 소스)에서 **AWS events or EventBridge partner events**를 선택합니다.

   1. **Event pattern**(이벤트 패턴) 섹션에서 **Event source**(이벤트 소스)에 대해 **AWS service**가 선택되어 있는지 확인하고 **AWS service**에 대해 **EC2**를 선택합니다.

   1. **Event type**(이벤트 유형)에서 **EBS Snapshot Notification**(EBS 스냅샷 알림)을 선택하고 **Specific event(s)**(특정 이벤트)를 선택한 다음 **createSnapshot**을 선택합니다.

   1. **특정 결과(Specific result(s))**를 선택한 다음 **성공(succeeded)**을 선택합니다.

   1. **다음**을 선택합니다.

1. **Step 3: Select targets**(3단계: 대상 선택)에서 다음을 수행합니다.

   1. **대상 유형**에서 **AWS 서비스**를 선택합니다.

   1. **Select target**(대상 선택)에서 **Lambda function**(Lambda 함수)을 선택하고 **Function**(함수)에서 이전에 생성한 함수를 선택합니다.

   1. **Next**(다음)를 선택합니다.

1. **Step 4: Configure tags**(4단계: 태그 구성)에서 필요한 경우 규칙에 대한 태그를 지정하고 **Next**(다음)를 선택합니다.

1. **Step 5: Review and create**(5단계: 검토 및 생성)에서 규칙을 검토한 다음 **Create rule**(규칙 생성)을 선택합니다.

이제 **규칙** 탭에 규칙이 표시됩니다. 표시된 예에서 구성된 이벤트는 다음에 스냅샷을 복사할 때 EBS가 발생시킵니다.