All files / src/activemq activemq-broker-redundant-pair.ts

100% Statements 98/98
100% Branches 1/1
100% Functions 1/1
100% Lines 98/98

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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 981x 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 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x
/*
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
import { Aws, Fn, Token } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { IActiveMqBroker } from './activemq-broker';
import { ActiveMqBrokerDeploymentBase, ActiveMqBrokerDeploymentProps } from './activemq-broker-deployment';
import { BrokerDeploymentMode } from '../broker-deployment-mode';
 
export interface ActiveMqBrokerRedundantPairProps extends ActiveMqBrokerDeploymentProps {
 
}
 
/**
 * A representation of an active/standby broker that is comprised of two brokers in two different Availability Zones.
 *
 * see: https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/active-standby-broker-deployment.html
 */
export class ActiveMqBrokerRedundantPair extends ActiveMqBrokerDeploymentBase {
 
  /**
   * The first broker of the redundant pair for the deployment.
   */
  public readonly first: IActiveMqBroker;
 
  /**
   * The second broker of the redundant pair for the deployment.
   */
  public readonly second: IActiveMqBroker;
 
  constructor(scope: Construct, id: string, props: ActiveMqBrokerRedundantPairProps) {
    super(scope, id, {
      ...props,
      deploymentMode: BrokerDeploymentMode.ACTIVE_STANDBY_MULTI_AZ,
    });
 
    this.first = {
      endpoints: {
        amqp: {
          url: Fn.select(0, this._resource.attrAmqpEndpoints),
          port: Token.asNumber(Fn.select(2, Fn.split(':', Fn.select(0, this._resource.attrAmqpEndpoints)))),
        },
        stomp: {
          url: Fn.select(0, this._resource.attrStompEndpoints),
          port: Token.asNumber(Fn.select(2, Fn.split(':', Fn.select(0, this._resource.attrStompEndpoints)))),
        },
        openWire: {
          url: Fn.select(0, this._resource.attrOpenWireEndpoints),
          port: Token.asNumber(Fn.select(2, Fn.split(':', Fn.select(0, this._resource.attrOpenWireEndpoints)))),
        },
        mqtt: {
          url: Fn.select(0, this._resource.attrMqttEndpoints),
          port: Token.asNumber(Fn.select(2, Fn.split(':', Fn.select(0, this._resource.attrMqttEndpoints)))),
        },
        wss: {
          url: Fn.select(0, this._resource.attrWssEndpoints),
          port: Token.asNumber(Fn.select(2, Fn.split(':', Fn.select(0, this._resource.attrWssEndpoints)))),
        },
        console: {
          url: `https://${this.id}-1.mq.${Aws.REGION}.amazonaws.com:8162`,
          port: 8162,
        },
      },
      ipAddress: Fn.select(0, this._resource.attrIpAddresses),
    };
 
    this.second = {
      endpoints: {
        amqp: {
          url: Fn.select(1, this._resource.attrAmqpEndpoints),
          port: Token.asNumber(Fn.select(2, Fn.split(':', Fn.select(1, this._resource.attrAmqpEndpoints)))),
        },
        stomp: {
          url: Fn.select(1, this._resource.attrStompEndpoints),
          port: Token.asNumber(Fn.select(2, Fn.split(':', Fn.select(1, this._resource.attrStompEndpoints)))),
        },
        openWire: {
          url: Fn.select(1, this._resource.attrOpenWireEndpoints),
          port: Token.asNumber(Fn.select(2, Fn.split(':', Fn.select(1, this._resource.attrOpenWireEndpoints)))),
        },
        mqtt: {
          url: Fn.select(1, this._resource.attrMqttEndpoints),
          port: Token.asNumber(Fn.select(2, Fn.split(':', Fn.select(1, this._resource.attrMqttEndpoints)))),
        },
        wss: {
          url: Fn.select(1, this._resource.attrWssEndpoints),
          port: Token.asNumber(Fn.select(2, Fn.split(':', Fn.select(1, this._resource.attrWssEndpoints)))),
        },
        console: {
          url: `https://${this.id}-2.mq.${Aws.REGION}.amazonaws.com:8162`,
          port: 8162,
        },
      },
      ipAddress: Fn.select(1, this._resource.attrIpAddresses),
    };
  }
}