in source/patterns/@aws-solutions-constructs/core/lib/alb-helper.ts [202:259]
export function CheckAlbProps(props: any) {
let errorMessages = '';
let errorFound = false;
if (props.listenerProps?.certificateArns) {
errorMessages += "certificateArns is deprecated. Please supply certificates using props.listenerProps.certificates\n";
errorFound = true;
}
if (
((props.existingLoadBalancerObj &&
props.existingLoadBalancerObj.listeners.length === 0) ||
!props.existingLoadBalancerObj) &&
!props.listenerProps
) {
errorMessages += "When adding the first listener and target to a load balancer, listenerProps must be specified and include at least a certificate or protocol: HTTP\n";
errorFound = true;
}
if (
props.existingLoadBalancerObj &&
props.existingLoadBalancerObj.listeners.length > 0 &&
props.listenerProps
) {
errorFound = true;
errorMessages += "This load balancer already has a listener, listenerProps may not be specified\n";
}
if (
props.existingLoadBalancerObj &&
props.existingLoadBalancerObj.listeners.length > 0 &&
!props.ruleProps
) {
errorFound = true;
errorMessages += "When adding a second target to an existing listener, there must be rules provided\n";
}
// Check construct specific invalid inputs
if (props.existingLoadBalancerObj && !props.existingVpc) {
errorFound = true;
errorMessages += "An existing ALB is already in a VPC, that VPC must be provided in props.existingVpc for the rest of the construct to use.\n";
}
if (props.loadBalancerProps?.vpc) {
errorFound = true;
errorMessages += 'Specify any existing VPC at the construct level, not within loadBalancerProps.\n';
}
if (props.existingLoadBalancerObj) {
printWarning(
"The public/private property of an existing ALB must match the props.publicApi setting provided."
);
}
if (errorFound) {
throw new Error(errorMessages);
}
}