in source/patterns/@aws-solutions-constructs/core/lib/fargate-helper.ts [196:264]
export function CheckFargateProps(props: any) {
let errorMessages = "";
let errorFound = false;
if (
props.existingFargateServiceObject &&
(props.existingImageObject ||
props.ecrImageVersion ||
props.containerDefinitionProps ||
props.fargateTaskDefinitionProps ||
props.ecrRepositoryArn ||
props.fargateServiceProps ||
props.clusterProps)
) {
errorFound = true;
errorMessages +=
"If you provide an existingFargateServiceObject, you cannot provide any props defining a new service\n";
}
if (
props.existingImageObject &&
(props.ecrImageVersion || props.ecrRepositoryArn)
) {
errorFound = true;
errorMessages +=
"If you provide an existingImageObject then you cannot provide an ecrRepositoryArn nor ecrImageVersion\n";
}
// Confirm no network information in Target Group Props
if (props.targetGroupProps?.vpc) {
errorFound = true;
errorMessages +=
"Provide all VPC info at Construct level, not within targetGroupProps\n";
}
if (props.fargateServiceProps?.taskDefinition) {
errorFound = true;
errorMessages +=
"The construct cannot accept an existing task definition in fargateServiceProps\n";
}
if (props.fargateServiceProps?.cluster && props.clusterProps) {
errorFound = true;
errorMessages +=
"If you provide a cluster in fargateServiceProps then you cannot provide clusterProps\n";
}
if (props.clusterProps?.vpc) {
errorFound = true;
errorMessages +=
"All services in the construct use the construct VPC, you cannot specify a VPC in clusterProps\n";
}
if (
(props.existingFargateServiceObject ||
props.existingContainerDefinitionObject) &&
(!props.existingFargateServiceObject ||
!props.existingContainerDefinitionObject ||
!props.existingVpc)
) {
errorFound = true;
errorMessages +=
"If an existing Service is indicated by supplying either existingFargateServiceObject or existingContainerDefinitionObject, then existingFargateServiceObject, existingContainerDefinitionObject, and existingVpc must all be provided\n";
}
if (errorFound) {
throw new Error(errorMessages);
}
}