Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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', {