Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,9 @@
"reactnative",
"realtime",
"reCaptcha",
"recordcache",
"RecyclerView",
"retryable",
"redirect_to",
"referrerpolicy",
"refetches",
Expand Down Expand Up @@ -1346,6 +1348,7 @@
"UIViewController",
"unauth",
"Unauth",
"uncategorized",
"uncommenting",
"unencrypted",
"unioned",
Expand Down
3 changes: 2 additions & 1 deletion src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ export const Layout = ({
)}
{(asPathWithNoHash.includes('/push-notifications/') ||
asPathWithNoHash.includes('/analytics/') ||
asPathWithNoHash.includes('/in-app-messaging/')) && (
asPathWithNoHash.includes('/in-app-messaging/')) &&
!asPathWithNoHash.includes('/kinesis') && (
<PinpointEOLBanner />
)}
{asPathWithNoHash.includes('/interactions/') && (
Expand Down
7 changes: 7 additions & 0 deletions src/directory/directory.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ export const directory = {
path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/set-up-analytics/index.mdx',
section: 'backend'
},
{
path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/kinesis/index.mdx',
section: 'backend'
},
{
path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/existing-resources/index.mdx',
section: 'backend'
Expand Down Expand Up @@ -800,6 +804,9 @@ export const directory = {
{
path: 'src/pages/[platform]/frontend/analytics/index.mdx',
children: [
{
path: 'src/pages/[platform]/frontend/analytics/kinesis/index.mdx'
},
{
path: 'src/pages/[platform]/frontend/analytics/record-events/index.mdx'
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { getCustomStaticPath } from '@/utils/getCustomStaticPath';

export const meta = {
title: 'Kinesis Data Streams',
description: 'Set up an Amazon Kinesis Data Stream and configure IAM permissions for the Amplify Kinesis Data Streams client.',
platforms: [
'android',
'flutter',
'swift'
],
};

export const getStaticPaths = async () => {
return getCustomStaticPath(meta.platforms);
};

export function getStaticProps(context) {
return {
props: {
platform: context.params.platform,
meta
}
};
}

Use the [AWS Cloud Development Kit (AWS CDK)](https://docs.aws.amazon.com/cdk/latest/guide/home.html) to create an [Amazon Kinesis Data Stream](https://aws.amazon.com/kinesis/data-streams/) and grant your app the permissions it needs. For more on adding custom AWS resources to your Amplify backend, see [Custom resources](/[platform]/build-a-backend/add-aws-services/custom-resources/).

## Set up a Kinesis stream

```ts title="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 stream
const kinesisStream = new Stream(kinesisStack, "KinesisStream", {
streamName: "myKinesisStream",
shardCount: 1,
});

// Grant PutRecords permission to authenticated users
const 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:

```json
{
"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](https://docs.aws.amazon.com/streams/latest/dev/learning-kinesis-module-one-iam.html).

## Next steps

Use the [Kinesis Data Streams client](/[platform]/frontend/analytics/kinesis/) to stream data from your app.
Loading
Loading