1. Answers
  2. AWS Kinesis Video Streams media playback

How do I set up AWS Kinesis Video Streams media playback with Pulumi?

In this guide, we will create an AWS Kinesis Video Stream using Pulumi. Kinesis Video Streams enable you to securely ingest, process, and store video streams for applications that require real-time video processing and analysis. We will also set up the necessary IAM roles and policies to allow the Kinesis Video Stream to function correctly.

Key Points

  • Create a Kinesis Video Stream.
  • Set up IAM roles and policies for the Kinesis Video Stream.
  • Ensure the Kinesis Video Stream is configured for media playback.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// Create a Kinesis Video Stream
const videoStream = new aws.kinesis.VideoStream("videoStream", {
    name: "my-video-stream",
    dataRetentionInHours: 24, // Retain data for 24 hours
    mediaType: "video/h264",  // Specify the media type
    tags: {
        Environment: "dev",
    },
});

// Create an IAM Role for Kinesis Video Stream
const kinesisRole = new aws.iam.Role("kinesisRole", {
    assumeRolePolicy: JSON.stringify({
        Version: "2012-10-17",
        Statement: [
            {
                Action: "sts:AssumeRole",
                Principal: {
                    Service: "kinesisvideo.amazonaws.com",
                },
                Effect: "Allow",
            },
        ],
    }),
});

// Attach a policy to the role to allow Kinesis Video Stream actions
const kinesisPolicy = new aws.iam.RolePolicy("kinesisPolicy", {
    role: kinesisRole.id,
    policy: JSON.stringify({
        Version: "2012-10-17",
        Statement: [
            {
                Effect: "Allow",
                Action: [
                    "kinesisvideo:ConnectAsMaster",
                    "kinesisvideo:ConnectAsViewer",
                    "kinesisvideo:GetMedia",
                    "kinesisvideo:GetMediaForFragmentList",
                ],
                Resource: videoStream.arn,
            },
        ],
    }),
});

// Export the name and ARN of the video stream
export const streamName = videoStream.name;
export const streamArn = videoStream.arn;

Summary

In this guide, we set up an AWS Kinesis Video Stream using Pulumi. We created the video stream, set up an IAM role and policy to allow the necessary actions for the video stream, and exported the stream’s name and ARN for further use. This setup allows for the secure ingestion, processing, and playback of video streams in real-time.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up