Looking for how to use this in your app?See Frontend Libraries →
Kinesis Data Streams
Use the AWS Cloud Development Kit (AWS CDK) to create an Amazon Kinesis Data Stream and grant your app the permissions it needs. For more on adding custom AWS resources to your Amplify backend, see Custom resources.
Set up a Kinesis stream
amplify/backend.ts
import { defineBackend } from "@aws-amplify/backend";import { auth } from "./auth/resource";import { data } from "./data/resource";import { Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";import { Stream } from "aws-cdk-lib/aws-kinesis";import { Stack } from "aws-cdk-lib/core";
const backend = defineBackend({ auth, data,});
const kinesisStack = backend.createStack("kinesis-stack");
// Create a Kinesis streamconst kinesisStream = new Stream(kinesisStack, "KinesisStream", { streamName: "myKinesisStream", shardCount: 1,});
// Grant PutRecords permission to authenticated usersconst kinesisPolicy = new Policy(kinesisStack, "KinesisPolicy", { statements: [ new PolicyStatement({ actions: ["kinesis:PutRecords"], resources: [kinesisStream.streamArn], }), ],});
backend.auth.resources.authenticatedUserIamRole.attachInlinePolicy(kinesisPolicy);If you are not using the CDK, ensure your authenticated IAM role has the kinesis:PutRecords permission on your target stream:
{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": "kinesis:PutRecords", "Resource": "arn:aws:kinesis:<region>:<account-id>:stream/<stream-name>" }]}For more information, see the Amazon Kinesis Developer Documentation.
Next steps
Use the Kinesis Data Streams client to stream data from your app.