Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
zone: domainZone,
recordName: props.domainName,
target: AddressRecordTarget.fromAlias(new LoadBalancerTarget(loadBalancer)),
});
// Primary traffic listener
const listener = loadBalancer.addListener('PublicListener', {
port: 443,
open: true,
certificateArns: [certificateArn]
});
// Second listener for test traffic
let testListener = loadBalancer.addListener('TestListener', {
port: 9002, // port for testing
protocol: ApplicationProtocol.HTTPS,
open: true,
certificateArns: [certificateArn]
});
// First target group for blue fleet
const tg1 = listener.addTargets('ECS', {
port: 80,
targets: [ // empty to begin with
new (class EmptyIpTarget implements IApplicationLoadBalancerTarget {
attachToApplicationTargetGroup(_: ApplicationTargetGroup): LoadBalancerTargetProps {
return { targetType: TargetType.IP };
}
})()
],
deregistrationDelay: cdk.Duration.seconds(30),
healthCheck: {
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', {
domainName: props.domainName,
hostedZone: props.domainZone
});
}
}
if (this.certificate !== undefined) {
this.listener.addCertificateArns('Arns', [this.certificate.certificateArn]);
}
this.desiredCount = props.desiredCount || 1;
const internetFacing = props.publicLoadBalancer !== undefined ? props.publicLoadBalancer : true;
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) {