

# Using Amazon Chime SDK media pipeline events
<a name="media-pipe-events"></a>

Each type of media pipeline sends lifecycle events, which you can use to trigger notifications and initiate downstream workflows. Some examples of using media pipeline events include:
+ Processing captured media after a media pipeline has completed.
+ Notifying meeting participants if a media pipeline has a temporary failure.
+ Stopping a meeting if a media pipeline fails permanently.

You can send events to Amazon EventBridge, Amazon Simple Notification Service (SNS), and Amazon Simple Queue Service (SQS). For more information, refer to [Events from AWS services](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-service-event.html) in the *Amazon EventBridge User Guide*.

## Amazon Chime SDK media pipeline created
<a name="media-pipeline-create"></a>

The Amazon Chime SDK sends this event when the media pipeline is created.

**Example: Event data**  
 The following is example data for this event.

```
{
    "version": "0", 
    "id": "5ee6265a-0a40-104e-d8fd-a3b4bdd78483", 
    "detail-type": "Chime Media Pipeline State Change", 
    "source": "aws.chime", 
    "account": "111122223333", 
    "time": "2021-07-28T20:20:49Z", 
    "region": "us-east-1", 
    "resources": [], 
    "detail": {
        "version": "0", 
        "eventType": "chime:MediaPipelineInProgress", 
        "timestamp": 1627503649251, 
        "meetingId": "1e6bf4f5-f4b5-4917-b8c9-bda45c340706", 
        "externalMeetingId": "Meeting_Id",
        "mediaPipelineId": "e40ee45e-2ed1-408e-9156-f52b8208a491", 
        "mediaRegion": "ap-southeast-1"
    }
}
```

## Amazon Chime SDK media pipeline deleted
<a name="media-pipeline-delete"></a>

The Amazon Chime SDK sends this event after the media pipeline stops successfully. 

**Example: Event data**  
The following is example data for this event.

```
{
    "version": "0",
    "id": "9e11e429-97fd-9532-5670-fac3f7abc05f",
    "detail-type": "Chime Media Pipeline State Change",
    "source": "aws.chime",
    "account": "365135496707",
    "time": "2021-07-28T20:21:50Z",
    "region": "us-east-1",
    "resources": [],
    "detail": {
        "version": "0",
        "eventType": "chime:MediaPipelineDeleted",
        "timestamp": 1627503710485,
        "meetingId": "1e6bf4f5-f4b5-4917-b8c9-bda45c340706",
        "externalMeetingId": "Meeting_Id",
        "mediaPipelineId": "e40ee45e-2ed1-408e-9156-f52b8208a491",
        "mediaRegion": "ap-southeast-1"
    }
}
```

## Amazon Chime SDK media pipeline has a temporary failure
<a name="pipeline-temp-failure"></a>

The Amazon Chime SDK sends this event when the media pipeline has a temporary failure.

**Example: Event data**  
The following is example data for this event.

```
{
    "version": "0",
    "id": "abc141e1-fc2e-65e8-5f18-ab5130f1035a",
    "detail-type": "Chime Media Pipeline State Change",
    "source": "aws.chime",
    "account": "365135496707",
    "time": "2021-07-28T21:16:42Z",
    "region": "us-east-1",
    "resources": [],
    "detail": {
        "version": "0",
        "eventType": "chime:MediaPipelineTemporaryFailure",
        "timestamp": 1627507002882,
        "meetingId": "7a5434e3-724a-4bbb-9eb6-2fb209dc0706",
        "externalMeetingId": "Meeting_Id",
        "mediaPipelineId": "ebd62f4e-04a9-426d-bcb0-974c0f266400",
        "mediaRegion": "eu-south-1"
    }
}
```

## Amazon Chime SDK media pipeline in progress
<a name="pipeline-in-progress"></a>

The Amazon Chime SDK sends this event when the media pipeline begins capturing artifacts.

**Example: Event data**  
The following is example data for this event.

```
{
    "version": "0",
    "id": "9e11e429-97fd-9532-5670-fac3f7abc05f",
    "detail-type": "Chime Media Pipeline State Change",
    "source": "aws.chime",
    "account": "365135496707",
    "time": "2021-07-28T20:21:50Z",
    "region": "us-east-1",
    "resources": [],
    "detail": {
        "version": "0",
        "eventType": "chime:MediaPipelineInProgress",
        "timestamp": 1627503710485?,
        "meetingId": "1e6bf4f5-f4b5-4917-b8c9-bda45c340706",
        "externalMeetingId": "Meeting_Id",
        "mediaPipelineId": "e40ee45e-2ed1-408e-9156-f52b8208a491",
        "mediaRegion": "ap-southeast-1"
    }
}
```

## Amazon Chime SDK media pipeline permanent failure
<a name="pipeline-perm-failure"></a>

The Amazon Chime SDK sends this event when a media pipeline fails permanently.

**Example: Event data**  
The following is example data for this event.

```
{
    "version": "0",
    "id": "9e11e429-97fd-9532-5670-fac3f7abc05f",
    "detail-type": "Chime Media Pipeline State Change",
    "source": "aws.chime",
    "account": "365135496707",
    "time": "2021-07-28T20:21:50Z",
    "region": "us-east-1",
    "resources": [],
    "detail": {
        "version": "0",
        "eventType": "chime:MediaPipelinePermanentFailure",
        "timestamp": 1627503710485,
        "meetingId": "1e6bf4f5-f4b5-4917-b8c9-bda45c340706",
        "externalMeetingId": "Meeting_Id",
        "mediaPipelineId": "e40ee45e-2ed1-408e-9156-f52b8208a491",
        "mediaRegion": "ap-southeast-1"
    }
}
```

# Setting Amazon S3 bucket permissions for Amazon Chime SDK media pipelines
<a name="s3-permissions"></a>

If you haven't created an Amazon S3 bucket, make sure you create yours in the account and Region where you host meetings. Also, make sure you grant adequate permissions to the service. For more information about creating an Amazon S3 bucket, see [Creating an Amazon S3 bucket for Amazon Chime SDK media capture pipelines](create-s3-bucket.md).

# Sending Amazon Chime SDK media pipeline events to CloudTrail
<a name="pipeline-cloudtrail"></a>

AWS enables CloudTrail for you when you create your AWS account. When a user calls a supported API in the media pipeline SDK, CloudTrail logs that activity for that API in **Event history**, along with other AWS events. You can view, search, and download the media pipeline events in your AWS account. For more information, see [Viewing Events with CloudTrail Event History](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html) in the *CloudTrail User Guide*.

For an ongoing record of media pipeline events, you can create a *trail*. A trail enables CloudTrail to deliver log files to your Amazon S3 bucket. The following example shows a media pipeline trail. The data includes the user that called the API, the IAM role used to call the API, and timestamps. For more information about using CloudTrail see [Logging and monitoring](https://docs.aws.amazon.com/chime-sdk/latest/ag/monitoring-overview.html) in the *Amazon Chime SDK Administrator Guide*.

```
{
   "Records": [    
   {
      "eventVersion": "1.08",
      "userIdentity": {
          "type": "AssumedRole",
          "principalId": "ABCDEFGHIJKLMNOPQRSTUV:user-name",
          "arn": "arn:aws:sts::123456789101:assumed-role/role-name/user-name",
          "accountId": "109876543210",
          "accessKeyId": "ABCDEFGHIJKLMNOPQRSTUV",
          "sessionContext": {
              "sessionIssuer": {
                  "type": "Role",
                  "principalId": "ABCDEFGHIJKLMNOPQRSTUV",
                  "arn": "arn:aws:iam::109876543210:role/role-name",
                  "accountId": "012345678910",
                  "userName": "user-name"
                  },
          "webIdFederationData": {},
          "attributes": {
              "mfaAuthenticated": "false",
              "creationDate": "2022-03-08T19:34:55Z"
              }
          }
      },
      "eventTime": "2022-03-08T20:28:41Z",
     "eventSource": "chime-sdk-media-pipelines.amazonaws.com",
     "eventName": "CreateMediaCapturePipeline",
     "awsRegion": "us-east-1",
     "sourceIPAddress": "127.0.0.1",
     "userAgent": "[]/[]",
     "requestParameters": {
         "sourceType": "ChimeSdkMeeting",
         "sourceArn": "Hidden_For_Security_Reasons",
         "sinkType": "S3Bucket",
         "sinkArn": "Hidden_For_Security_Reasons",
         "chimeSdkMeetingConfiguration": {
             "artifactsConfiguration": {
                 "audio": {
                    "muxType": "AudioOnly"
                 },
            "video": {
                "state": "Enabled",
                "muxType": "VideoOnly"
                },
            "content": {
                "state": "Enabled",
                "muxType": "ContentOnly"
                }
            }
        }
      },
     "responseElements": {
        "mediaCapturePipeline": {
        "mediaPipelineId": "pipeline-uuid",
        "sourceType": "ChimeSdkMeeting",
        "sourceArn": "Hidden_For_Security_Reasons",
        "status": "Initializing",
        "sinkType": "S3Bucket",
        "sinkArn": "Hidden_For_Security_Reasons",
        "createdTimestamp": "2022-03-08T20:28:41.336Z",
        "updatedTimestamp": "2022-03-08T20:28:41.463Z",
        "chimeSdkMeetingConfiguration": {
            "artifactsConfiguration": {
                "audio": {
                    "muxType": "AudioOnly"
                },
            "video": {
                "state": "Enabled",
                 "muxType": "VideoOnly"
                 },
             "content": {
                 "state": "Enabled",
                 "muxType": "ContentOnly"
                 }
              }
            }
          }
      },
      "requestID": "request-id",
      "eventID": "event-id",
     "readOnly": false,
      "eventType": "AwsApiCall",
      "managementEvent": true,
      "eventCategory": "Management",
      "recipientAccountId": "112233445566",
      "tlsDetails": {
          "tlsVersion": "TLSv1.2",
          "clientProvidedHostHeader": "example.com"
       }
    },  
  ]
}
```