How to use the @aws-cdk/aws-elasticloadbalancingv2.ApplicationProtocol.HTTP function in @aws-cdk/aws-elasticloadbalancingv2

To help you get started, we’ve selected a few @aws-cdk/aws-elasticloadbalancingv2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-cdk / packages / @aws-cdk / aws-ecs-patterns / lib / base / application-load-balanced-service-base.ts View on Github external
const lbProps = {
      vpc: this.cluster.vpc,
      internetFacing
    };

    this.loadBalancer = props.loadBalancer !== undefined ? props.loadBalancer : new ApplicationLoadBalancer(this, 'LB', lbProps);

    const targetProps = {
      port: 80
    };

    if (props.certificate !== undefined && props.protocol !== undefined && props.protocol !== ApplicationProtocol.HTTPS) {
      throw new Error('The HTTPS protocol must be used when a certificate is given');
    }
    const protocol = props.protocol !== undefined ? props.protocol : (props.certificate ? ApplicationProtocol.HTTPS : ApplicationProtocol.HTTP);

    this.listener = this.loadBalancer.addListener('PublicListener', {
      protocol,
      open: true
    });
    this.targetGroup = this.listener.addTargets('ECS', targetProps);

    if (protocol === ApplicationProtocol.HTTPS) {
      if (typeof props.domainName === 'undefined' || typeof props.domainZone === 'undefined') {
        throw new Error('A domain name and zone is required when using the HTTPS protocol');
      }

      if (props.certificate !== undefined) {
        this.certificate = props.certificate;
      } else {
        this.certificate = new DnsValidatedCertificate(this, 'Certificate', {