All files / src/rabbitmq/lambda rabbitmq-event-source.ts

88.88% Statements 40/45
66.66% Branches 2/3
100% Functions 1/1
88.88% Lines 40/45

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 36 37 38 39 40 41 42 43 44 451x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10x 10x 10x           6x 6x 1x
/*
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
import { IEventSource, SourceAccessConfigurationType } from 'aws-cdk-lib/aws-lambda';
import { EventSourceBase, EventSourceProps } from '../../mq-esm/event-source-base';
import { IRabbitMqBrokerDeployment } from '../rabbitmq-broker-deployment';
 
export interface RabbitMqEventSourceProps extends EventSourceProps {
  /**
   * The RabbitMQ broker deployment to receive messages from.
   */
  readonly broker: IRabbitMqBrokerDeployment;
 
  /**
   * he name of the RabbitMQ virtual host from which a queue will be the source of messages.
   *
   * @default - the default virtual host '/' will be used.
   */
  readonly virtualHost?: string;
}
 
/**
 * Represents an AWS Lambda Event Source Mapping for RabbitMQ. This event source will add additional permissions to
 * the AWS Lambda function's IAM Role following https://docs.aws.amazon.com/lambda/latest/dg/with-mq.html#events-mq-permissions
 */
export class RabbitMqEventSource extends EventSourceBase implements IEventSource {
  /**
   * Instantiates an AWS Lambda Event Source Mapping for RabbitMQ. This event source will add additional permissions to
   * the AWS Lambda function's IAM Role following https://docs.aws.amazon.com/lambda/latest/dg/with-mq.html#events-mq-permissions
   *
   * @param props properties of the RabbitMQ event source
   */
  constructor(props: RabbitMqEventSourceProps) {
    super(props, 'armq');
 
    if (props.virtualHost) {
      this.addToSourceAccessConfigurations({
        type: SourceAccessConfigurationType.of('VIRTUAL_HOST'),
        uri: props.virtualHost,
      });
    }
 
  }
}