Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import * as kinesis from '@aws-cdk/aws-kinesis'; import * as cdk from '@aws-cdk/core'; import {GenericRestApiAwsIntegration, GenericRestApiAwsIntegrationProps} from "./generic-rest-api-aws-integration" /** * Integrates a Kinesis Stream with ApiGateway (RestApi) by publishing Queue messages on http request */ export interface KinesisRestApiIntegrationProps extends GenericRestApiAwsIntegrationProps { /** * The target kinesis Queue to which messages will be sent by the RestApi Integration */ stream: kinesis.Stream; } export class KinesisRestApiIntegration extends GenericRestApiAwsIntegration { constructor(scope: cdk.Construct, id: string, props: KinesisRestApiIntegrationProps) { super(scope, id, props); } init(id: string, props: KinesisRestApiIntegrationProps) : void { this.requestTemplates["application/json"] = "{\"StreamName\":\""+ props.stream.streamName +"\",\"Data\":\"$util.base64Encode($input.body)\",\"PartitionKey\":\"$context.requestId\"}" this.successResponseTemplates["application/json"] = "{\"status\":\"message received\", \"messageId\": $input.json('SequenceNumber')}" this.failureResponseTemplates["application/json"] = "{\"status\":\"failed to process message\")}" this.integrationPath = undefined this.integrationAction = "PutRecord" this.awsService = "kinesis" } configureAwsService(id: string, props: KinesisRestApiIntegrationProps) : void { props.stream.grantWrite(this.integrationRole) } } |