aws-apigateway-kinesisstreams - AWS Solutions Constructs

aws-apigateway-kinesisstreams

All classes are under active development and subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.

Language Package
Python
aws_solutions_constructs.aws_apigateway_kinesisstreams
Typescript
@aws-solutions-constructs/aws-apigateway-kinesisstreams
Java
software.amazon.awsconstructs.services.apigatewaykinesisstreams

Overview

This pattern implements an Amazon API Gateway REST API connected to an Amazon Kinesis Data Stream.

Here is a minimal deployable pattern definition in TypeScript:

import { ApiGatewayToKinesisStreams, ApiGatewayToKinesisStreamsProps } from '@aws-solutions-constructs/aws-apigateway-kinesisstreams'; new ApiGatewayToKinesisStreams(this, 'test-apigw-kinesis', {});

Initializer

new ApiGatewayToKinesisStreams(scope: Construct, id: string, props: ApiGatewayToKinesisStreamsProps);

Parameters

Pattern Construct Props

Name Type Description
apiGatewayProps? api.RestApiProps Optional user-provided props to override the default props for the API Gateway REST API.
putRecordRequestTemplate? string API Gateway request template for the PutRecord action. If not provided, a default one will be used.
putRecordRequestModel? api.ModelOptions API Gateway request model for the PutRecord action. If not provided, a default one will be created.
putRecordsRequestTemplate? string API Gateway request template for the PutRecords action. If not provided, a default one will be used.
putRecordRequestModel? api.ModelOptions API Gateway request model for the PutRecords action. If not provided, a default one will be created.
existingStreamObj? kinesis.Stream An optional, existing Kinesis stream to be used instead of the default stream. If an existing stream is provided, the kinesisStreamProps property will be ignored.
kinesisStreamProps? kinesis.StreamProps Optional user-provided props to override the default props for the Kinesis stream.
logGroupProps? logs.LogGroupProps Optional user-provided props to override the default props for the CloudWatch Logs log group.

Pattern Properties

Name Type Description
apiGateway api.RestApi Returns an instance of the API Gateway REST API created by the pattern.
apiGatewayRole iam.Role Returns an instance of the IAM role created by the pattern for the API Gateway REST API.
apiGatewayCloudWatchRole iam.Role Returns an instance of the IAM role created by the pattern that enables access logging from the API Gateway REST API to CloudWatch.
apiGatewayLogGroup logs.LogGroup Returns an instance of the log group created by the pattern that API Gateway REST API access logs are sent to.
kinesisStream kinesis.Stream Returns an instance of the Kinesis stream created by the pattern.

Sample API Usage

Method Request Path Request Body Queue Action Description
POST /record
{ "data": "Hello World!", "partitionKey": "pk001" }
kinesis:PutRecord Writes a single data record into the stream.
POST /records
{ "records": [ { "data": "abc", "partitionKey": "pk001" }, { "data": "xyz", "partitionKey": "pk001" } ] }
kinesis:PutRecords Writes multiple data records into the stream in a single call.

Default settings

Out-of-the-box implementation of this pattern without any overrides will set the following defaults:

Amazon API Gateway

  • Deploy an edge-optimized API endpoint.

  • Enable CloudWatch logging for API Gateway.

  • Configure least privilege access IAM role for API Gateway.

  • Set the default authorizationType for all API methods to IAM.

  • Enable X-Ray tracing.

  • Validate request body before passing data to Kinesis.

Amazon Kinesis Data Stream

  • Configure least privilege access IAM role for Kinesis stream.

  • Enable server-side encryption for Kinesis Stream using AWS Managed KMS Key.

Architecture

GitHub

To view the code for this pattern, create/view issues and pull requests, and more:
@aws-solutions-constructs/aws-apigateway-kinesisstreams