AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: HTTP API direct integrations Resources: MyQueue: Type: AWS::SQS::Queue MyStream: Type: AWS::Kinesis::Stream Properties: ShardCount: 1 MyHttpApi: Type: AWS::Serverless::HttpApi Properties: DefinitionBody: 'Fn::Transform': Name: 'AWS::Include' Parameters: Location: './api.yaml' MyHttpApiRole: Type: "AWS::IAM::Role" Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Principal: Service: "apigateway.amazonaws.com" Action: - "sts:AssumeRole" Policies: - PolicyName: ApiDirectWriteToSQS PolicyDocument: Version: '2012-10-17' Statement: Action: - sqs:SendMessage Effect: Allow Resource: - !GetAtt MyQueue.Arn - PolicyName: ApiDirectWriteEventBridge PolicyDocument: Version: '2012-10-17' Statement: Action: - events:PutEvents Effect: Allow Resource: - !Sub arn:aws:events:${AWS::Region}:${AWS::AccountId}:event-bus/default - PolicyName: ApiDirectWriteKinesis PolicyDocument: Version: '2012-10-17' Statement: Action: - kinesis:PutRecord Effect: Allow Resource: - !GetAtt MyStream.Arn MyTriggeredLambda: Type: AWS::Serverless::Function Properties: CodeUri: src/ Handler: app.lambdaHandler Runtime: nodejs12.x Policies: - SQSPollerPolicy: QueueName: !GetAtt MyQueue.QueueName Events: SQSTrigger: Type: SQS Properties: Queue: !GetAtt MyQueue.Arn EventBridgeTrigger: Type: CloudWatchEvent Properties: Pattern: source: - "WebApp" KinesisTrigger: Type: Kinesis Properties: StartingPosition: TRIM_HORIZON Stream: !GetAtt MyStream.Arn Outputs: ApiEndpoint: Description: "HTTP API endpoint URL" Value: !Sub "https://${MyHttpApi}.execute-api.${AWS::Region}.amazonaws.com"