def _validate()

in cli/src/pcluster/validators/cluster_validators.py [0:0]


    def _validate(self, queues):
        multi_nic_queues = [
            queue
            for queue in queues
            for compute_resource in queue.compute_resources
            if compute_resource.max_network_cards > 1
        ]

        all_subnets_with_public_ips = {
            subnet.get("SubnetId")
            for subnet in AWSApi.instance().ec2.describe_subnets(
                {subnet_id for queue in multi_nic_queues for subnet_id in queue.networking.subnet_ids}
            )
            if subnet.get("MapPublicIpOnLaunch")
        }

        for queue in multi_nic_queues:
            if queue.networking.assign_public_ip:
                self._add_failure(
                    f"The queue {queue.name} contains an instance type with multiple network interfaces however the "
                    f"AssignPublicIp value is set to true. AWS public IPs can only be assigned to instances launched "
                    f"with a single network interface.",
                    FailureLevel.ERROR,
                )

            queue_subnets_with_public_ips = sorted(
                [subnet_id for subnet_id in queue.networking.subnet_ids if subnet_id in all_subnets_with_public_ips]
            )
            if queue_subnets_with_public_ips:
                self._add_failure(
                    f"The queue {queue.name} contains an instance type with multiple network interfaces however the "
                    f"subnets {queue_subnets_with_public_ips} is configured to automatically assign public IPs. AWS "
                    f"public IPs can only be assigned to instances launched with a single network interface.",
                    FailureLevel.ERROR,
                )