Guide · Amazon IVS · Recording to S3 & EventBridge Notifications

Amazon IVS Recording to S3 for MCP Servers — Auto-Record Configuration, Thumbnails, and EventBridge Events

Amazon IVS records live streams to S3 automatically via RecordingConfiguration — a reusable resource you create once, attach to one or more channels, and forget. Every stream segment is written as HLS to a structured S3 path, with optional JPEG thumbnails at a configurable interval. EventBridge emits IVS Recording State Change events when recording starts, stops, or fails — your MCP server or downstream Lambda can react to these events to trigger post-processing, generate signed playback URLs for VOD, or alert operators when a recording fails mid-stream. This guide covers creating and managing recording configurations, thumbnail settings, S3 path patterns, the IAM trust policy IVS requires to write to your bucket, EventBridge event shapes, and the production gotchas that cause silent recording failures.

TL;DR

Create a RecordingConfiguration with an S3 destination and attach its ARN to channel(s) via CreateChannel or UpdateChannel. IVS assumes an IAM service role to write HLS segments and thumbnail files; that role needs s3:PutObject on your bucket with a trust policy allowing ivs.amazonaws.com. Thumbnails require explicit configuration in thumbnailConfiguration — they are disabled by default. S3 output paths follow the pattern <prefix>/<channel-id>/<stream-id>/events/recording-started.json and segment files. Subscribe to EventBridge aws.ivs source for IVS Recording State Change to trigger post-processing. If the recording configuration is in CREATE_FAILED state, the most common cause is a missing or incorrect S3 bucket policy — not an IAM role issue.

RecordingConfiguration lifecycle

A RecordingConfiguration is a reusable IVS resource that specifies an S3 destination, thumbnail settings, and recording mode. You create it once and attach it to any number of channels. Deleting or modifying a recording configuration does not affect currently active streams on attached channels — changes take effect on the next stream start.

Recording configurations move through states: CREATING, ACTIVE, and CREATE_FAILED. Poll GetRecordingConfigurationCommand after creation until the state reaches ACTIVE before attaching to a channel. Creation typically takes 10–30 seconds; CREATE_FAILED means the IAM service role or S3 bucket policy has a problem — not a transient failure.

import {
  IvsClient,
  CreateRecordingConfigurationCommand,
  GetRecordingConfigurationCommand,
  DeleteRecordingConfigurationCommand,
  UpdateChannelCommand,
  type RecordingConfiguration
} from '@aws-sdk/client-ivs';

const ivs = new IvsClient({ region: 'us-east-1' });

async function createRecordingConfig(params: {
  name: string;
  bucketName: string;
  prefix?: string;
  thumbnailIntervalSeconds?: number;
  thumbnailResolution?: 'FULL_HD' | 'HD' | 'SD' | 'LOWEST_RESOLUTION';
  recordingMode?: 'SEQUENTIAL' | 'INTERVAL';
  targetIntervalSeconds?: number; // for INTERVAL mode
}): Promise<RecordingConfiguration> {
  const response = await ivs.send(new CreateRecordingConfigurationCommand({
    name: params.name,
    destinationConfiguration: {
      s3: {
        bucketName: params.bucketName,
      },
    },
    ...(params.prefix && {
      destinationConfiguration: {
        s3: { bucketName: params.bucketName },
      },
    }),
    thumbnailConfiguration: params.thumbnailIntervalSeconds
      ? {
          recordingMode: params.recordingMode ?? 'INTERVAL',
          targetIntervalSeconds: params.thumbnailIntervalSeconds ?? 60,
          resolution: params.thumbnailResolution ?? 'SD',
          storage: ['LATEST', 'SEQUENTIAL'],
        }
      : {
          recordingMode: 'DISABLED',
        },
    recordingReconnectWindowSeconds: 60, // allow up to 60s reconnect before creating new recording
    tags: {},
  }));

  if (!response.recordingConfiguration?.arn) {
    throw new Error('CreateRecordingConfiguration returned no ARN');
  }

  // Poll until ACTIVE or CREATE_FAILED
  for (let i = 0; i < 30; i++) {
    await new Promise(r => setTimeout(r, 2000));
    const { recordingConfiguration } = await ivs.send(
      new GetRecordingConfigurationCommand({ arn: response.recordingConfiguration.arn })
    );
    if (recordingConfiguration?.state === 'ACTIVE') {
      return recordingConfiguration;
    }
    if (recordingConfiguration?.state === 'CREATE_FAILED') {
      throw new Error(
        `RecordingConfiguration creation failed — check S3 bucket policy and IAM service role trust policy for ivs.amazonaws.com`
      );
    }
  }

  throw new Error('RecordingConfiguration did not reach ACTIVE state within 60 seconds');
}

async function attachToChannel(channelArn: string, recordingConfigurationArn: string): Promise<void> {
  await ivs.send(new UpdateChannelCommand({
    arn: channelArn,
    recordingConfigurationArn,
  }));
}

async function detachFromChannel(channelArn: string): Promise<void> {
  await ivs.send(new UpdateChannelCommand({
    arn: channelArn,
    recordingConfigurationArn: '', // empty string removes the recording configuration
  }));
}

The recordingReconnectWindowSeconds parameter controls how IVS handles brief broadcaster disconnects. If the broadcaster reconnects within the window (1–300 seconds), IVS appends segments to the existing recording rather than creating a new stream session directory. Set this to 60 seconds for broadcast use cases where encoder restarts or network blips are common; set it lower (or to 0) for recording-critical contexts where every disconnect should produce a separate recording file.

IAM service role and S3 bucket policy

IVS needs an IAM role to write HLS segments and thumbnails to your S3 bucket. The role uses a service-linked trust policy — ivs.amazonaws.com as the principal — not a user or Lambda execution role. You create the role in IAM, attach an S3 write policy, and pass its ARN in the channel or recording configuration. As of 2026, IVS creates a default service-linked role automatically when you create your first recording configuration, but the bucket policy on your S3 bucket must still explicitly allow the IVS service principal.

// IAM trust policy for the IVS service role
// (applied to the role IAM resource in CloudFormation or CDK)
const trustPolicy = {
  Version: '2012-10-17',
  Statement: [{
    Effect: 'Allow',
    Principal: { Service: 'ivs.amazonaws.com' },
    Action: 'sts:AssumeRole',
  }],
};

// IAM permissions policy attached to the role
const permissionsPolicy = {
  Version: '2012-10-17',
  Statement: [{
    Effect: 'Allow',
    Action: ['s3:PutObject', 's3:GetObject', 's3:ListBucket'],
    Resource: [
      'arn:aws:s3:::your-ivs-recordings-bucket',
      'arn:aws:s3:::your-ivs-recordings-bucket/*',
    ],
  }],
};

// S3 bucket policy (required in addition to IAM role)
const bucketPolicy = {
  Version: '2012-10-17',
  Statement: [{
    Effect: 'Allow',
    Principal: { Service: 'ivs.amazonaws.com' },
    Action: ['s3:PutObject', 's3:ListBucket'],
    Resource: [
      'arn:aws:s3:::your-ivs-recordings-bucket',
      'arn:aws:s3:::your-ivs-recordings-bucket/*',
    ],
    Condition: {
      StringEquals: { 'aws:SourceAccount': '123456789012' },
    },
  }],
};

Both the IAM role trust policy and the S3 bucket policy are required. A common failure mode: developers configure the IAM role correctly but forget the S3 bucket policy, resulting in CREATE_FAILED state on the recording configuration. The bucket policy's aws:SourceAccount condition scopes write access to your account, preventing the IVS service from writing to your bucket on behalf of other AWS accounts.

If your bucket has server-side encryption with a customer-managed KMS key, add kms:GenerateDataKey and kms:Decrypt permissions to the IVS role, and add a KMS key policy statement allowing ivs.amazonaws.com. Without this, the first segment write fails silently — you see no CREATE_FAILED state, but the recording event shows an error state transition in EventBridge.

S3 output path structure

IVS writes recordings to a structured S3 path under the bucket root. Understanding the path pattern is essential for downstream processing — Lambda triggers, Athena queries, and presigned URL generation all depend on knowing where files land.

// IVS recording S3 output path pattern:
//
// <channel-id>/<stream-id>/
//   events/
//     recording-started.json
//     recording-ended.json        (or recording-failed.json)
//   media/
//     hls/
//       master.m3u8
//       high/
//         playlist.m3u8
//         *.ts                    (HLS segments)
//       medium/
//         playlist.m3u8
//         *.ts
//       low/
//         playlist.m3u8
//         *.ts
//   thumbnails/
//     <timestamp>.jpg             (if thumbnails enabled)
//     latest.jpg                  (if LATEST storage enabled)

// Parse the channel-id from a channel ARN:
// arn:aws:ivs:us-east-1:123456789012:channel/AbCdEfGhIjKl
// channel-id = AbCdEfGhIjKl

function channelIdFromArn(arn: string): string {
  const parts = arn.split('/');
  if (parts.length < 2) throw new Error(`Invalid channel ARN: ${arn}`);
  return parts[parts.length - 1];
}

// Build the HLS master manifest URL for a completed recording
function buildVodUrl(
  bucketName: string,
  channelArn: string,
  streamId: string,
  region = 'us-east-1'
): string {
  const channelId = channelIdFromArn(channelArn);
  const key = `${channelId}/${streamId}/media/hls/master.m3u8`;
  return `https://${bucketName}.s3.${region}.amazonaws.com/${key}`;
}

// Or generate a presigned URL for private buckets
import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';

const s3 = new S3Client({ region: 'us-east-1' });

async function getPresignedVodUrl(
  bucketName: string,
  channelArn: string,
  streamId: string,
  expiresIn = 3600
): Promise<string> {
  const channelId = channelIdFromArn(channelArn);
  const key = `${channelId}/${streamId}/media/hls/master.m3u8`;
  return getSignedUrl(s3, new GetObjectCommand({ Bucket: bucketName, Key: key }), { expiresIn });
}

The recording-started.json event file contains the channel ARN, stream ID, recording start time, and S3 path. The recording-ended.json file (written when the stream ends normally) contains duration, segment count, and the master playlist path. These event files are written by IVS as the recording progresses; they are separate from EventBridge events but serve as a durable audit trail directly in S3.

Thumbnail configuration

Thumbnails are disabled by default. Enable them in thumbnailConfiguration by setting recordingMode to INTERVAL and specifying targetIntervalSeconds. IVS generates a JPEG thumbnail at approximately the specified interval; the actual interval may vary slightly depending on keyframe spacing in the ingest stream.

// Thumbnail configuration options
const thumbnailConfig = {
  recordingMode: 'INTERVAL' as const,
  targetIntervalSeconds: 30,            // thumbnail every 30 seconds
  resolution: 'SD' as const,            // FULL_HD | HD | SD | LOWEST_RESOLUTION
  storage: ['LATEST', 'SEQUENTIAL'] as const,
  // LATEST: overwrites thumbnails/latest.jpg each interval
  // SEQUENTIAL: writes thumbnails/<timestamp>.jpg for each interval
  // Can specify both, one, or neither (but then recordingMode must be DISABLED)
};

// Resolution options:
// FULL_HD: 1920x1080
// HD:      1280x720
// SD:      480x270
// LOWEST_RESOLUTION: matches lowest-bitrate rendition in transcoding ladder

Use LATEST storage alone when you need a live-updating preview thumbnail for a stream gallery without storing the entire thumbnail history. Use SEQUENTIAL storage alone when you need a timeline of thumbnails for VOD scrubbing. Use both when you need both a live preview and a historical record. Each SEQUENTIAL thumbnail is a separate S3 object — a 10-hour stream with 30-second intervals produces 1,200 objects in the thumbnails/ prefix.

The LOWEST_RESOLUTION option generates thumbnails at the resolution of the lowest-bitrate rendition in the channel's transcoding ladder. For BASIC channels (passthrough only), thumbnail resolution matches the ingest resolution regardless of this setting. For bandwidth-constrained thumbnail delivery (e.g., live stream grid with many channels), use LOWEST_RESOLUTION or SD — not FULL_HD.

EventBridge recording events

IVS emits IVS Recording State Change events to EventBridge when recording state transitions occur. Subscribe to these events to trigger post-processing Lambda functions, update a database with VOD URLs, or alert operators on recording failures.

// EventBridge event source: "aws.ivs"
// Event detail-type: "IVS Recording State Change"

interface IvsRecordingEvent {
  version: string;
  id: string;
  'detail-type': 'IVS Recording State Change';
  source: 'aws.ivs';
  account: string;
  time: string; // ISO 8601
  region: string;
  resources: string[]; // [channelArn]
  detail: {
    recording_status: 'Recording Start' | 'Recording End' | 'Recording Start Failure' | 'Recording End Failure';
    recording_status_reason?: string;
    channel_name: string;
    stream_id: string;
    recording_duration_ms?: number; // present on Recording End
    recording_s3_key_prefix?: string;
    recording_s3_bucket_name?: string;
    recording_sessions?: Array<{
      recording_s3_key_prefix: string;
    }>;
  };
}

// EventBridge rule pattern to match all IVS recording events
const eventPattern = {
  source: ['aws.ivs'],
  'detail-type': ['IVS Recording State Change'],
};

// Lambda handler for post-processing
async function handleRecordingEvent(event: IvsRecordingEvent): Promise<void> {
  const { recording_status, stream_id, recording_s3_key_prefix, recording_s3_bucket_name } = event.detail;

  if (recording_status === 'Recording End' && recording_s3_bucket_name && recording_s3_key_prefix) {
    const masterPlaylistKey = `${recording_s3_key_prefix}/media/hls/master.m3u8`;
    console.log(`Recording complete: s3://${recording_s3_bucket_name}/${masterPlaylistKey}`);
    // trigger transcoding, update database, generate presigned URL, etc.
  }

  if (recording_status === 'Recording Start Failure' || recording_status === 'Recording End Failure') {
    console.error(`Recording failure for stream ${stream_id}:`, event.detail.recording_status_reason);
    // alert operator via SNS, PagerDuty, etc.
  }
}

The Recording End event is not emitted until IVS has written the final HLS segment and closed the manifest. For a stream that ends normally, there is a 20–60 second delay between the broadcaster disconnecting and the Recording End event arriving — IVS needs time to flush the final segment buffer. The master.m3u8 file in S3 is not complete until after this event fires; attempting to serve it as VOD before Recording End will produce an HLS playlist that appears to end mid-stream.

If the broadcaster disconnects and reconnects within recordingReconnectWindowSeconds, no Recording End event fires for the first segment — only a final Recording End fires when the stream fully ends. The recording_sessions array in the event detail will contain multiple S3 key prefixes if the stream had multiple reconnect windows stitched together.

MCP tool handler: recording management

import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import {
  IvsClient,
  CreateRecordingConfigurationCommand,
  GetRecordingConfigurationCommand,
  UpdateChannelCommand,
  ListRecordingConfigurationsCommand
} from '@aws-sdk/client-ivs';
import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
import { z } from 'zod';

const ivs = new IvsClient({ region: process.env.AWS_REGION ?? 'us-east-1' });
const s3 = new S3Client({ region: process.env.AWS_REGION ?? 'us-east-1' });
const server = new McpServer({ name: 'ivs-recording', version: '1.0.0' });

server.tool(
  'create_recording_config',
  'Create an IVS RecordingConfiguration that auto-records streams to S3',
  {
    name: z.string().min(1).describe('Config name shown in AWS console'),
    bucketName: z.string().describe('S3 bucket name for recording output'),
    thumbnailIntervalSeconds: z.number().int().min(1).max(60).optional()
      .describe('Thumbnail interval in seconds (omit to disable thumbnails)'),
  },
  async ({ name, bucketName, thumbnailIntervalSeconds }) => {
    const response = await ivs.send(new CreateRecordingConfigurationCommand({
      name,
      destinationConfiguration: { s3: { bucketName } },
      thumbnailConfiguration: thumbnailIntervalSeconds
        ? { recordingMode: 'INTERVAL', targetIntervalSeconds: thumbnailIntervalSeconds, resolution: 'SD', storage: ['LATEST', 'SEQUENTIAL'] }
        : { recordingMode: 'DISABLED' },
      recordingReconnectWindowSeconds: 60,
    }));

    // Poll for ACTIVE
    const arn = response.recordingConfiguration!.arn!;
    for (let i = 0; i < 20; i++) {
      await new Promise(r => setTimeout(r, 3000));
      const { recordingConfiguration } = await ivs.send(
        new GetRecordingConfigurationCommand({ arn })
      );
      if (recordingConfiguration?.state === 'ACTIVE') {
        return { content: [{ type: 'text', text: JSON.stringify({ arn, state: 'ACTIVE' }, null, 2) }] };
      }
      if (recordingConfiguration?.state === 'CREATE_FAILED') {
        return {
          content: [{ type: 'text', text: 'CREATE_FAILED: check S3 bucket policy and IVS service role trust policy' }],
          isError: true,
        };
      }
    }
    return { content: [{ type: 'text', text: `Config created (ARN: ${arn}) but did not reach ACTIVE within 60s — check state manually` }] };
  }
);

server.tool(
  'attach_recording_to_channel',
  'Attach or detach a RecordingConfiguration from an IVS channel',
  {
    channelArn: z.string().startsWith('arn:aws:ivs:').describe('IVS channel ARN'),
    recordingConfigurationArn: z.string().optional()
      .describe('Recording config ARN to attach, or omit to detach'),
  },
  async ({ channelArn, recordingConfigurationArn }) => {
    await ivs.send(new UpdateChannelCommand({
      arn: channelArn,
      recordingConfigurationArn: recordingConfigurationArn ?? '',
    }));
    return {
      content: [{
        type: 'text',
        text: recordingConfigurationArn
          ? `Recording configuration attached to channel`
          : `Recording configuration detached from channel`,
      }],
    };
  }
);

server.tool(
  'get_vod_playback_url',
  'Generate a presigned S3 URL for a completed IVS stream recording',
  {
    bucketName: z.string().describe('S3 bucket containing the recording'),
    channelArn: z.string().startsWith('arn:aws:ivs:').describe('IVS channel ARN'),
    streamId: z.string().describe('IVS stream ID (from GetStream or EventBridge event)'),
    expiresInSeconds: z.number().int().min(60).max(604800).default(3600),
  },
  async ({ bucketName, channelArn, streamId, expiresInSeconds }) => {
    const channelId = channelArn.split('/').pop()!;
    const key = `${channelId}/${streamId}/media/hls/master.m3u8`;
    const url = await getSignedUrl(
      s3,
      new GetObjectCommand({ Bucket: bucketName, Key: key }),
      { expiresIn: expiresInSeconds }
    );
    return { content: [{ type: 'text', text: JSON.stringify({ vodUrl: url, key, expiresInSeconds }, null, 2) }] };
  }
);

const transport = new StdioServerTransport();
await server.connect(transport);

Production gotchas

GotchaSymptomFix
Missing S3 bucket policy CREATE_FAILED on recording configuration despite correct IAM role Add explicit bucket policy allowing ivs.amazonaws.com to s3:PutObject
KMS-encrypted bucket without IVS key grant Recording configuration reaches ACTIVE but recording event shows failure Add kms:GenerateDataKey + kms:Decrypt to IVS service role; update KMS key policy
Reading master.m3u8 before Recording End event HLS manifest appears truncated; players show stream cut off Wait for EventBridge Recording End event before serving VOD URL
Thumbnails disabled by default No JPEG files in thumbnails/ prefix despite successful recording Set thumbnailConfiguration.recordingMode = 'INTERVAL' explicitly
Recording End delay (20–60 s) Post-processing Lambda triggers before final segment is written Trigger Lambda on EventBridge Recording End event, not on stream disconnect
Multi-session recordings Post-processing handles only first recording_s3_key_prefix Iterate recording_sessions[] in the EventBridge event detail for reconnect scenarios
Empty string to detach recording config UpdateChannel with undefined does nothing Pass recordingConfigurationArn: '' (empty string) to detach

Related pages