code: def generate_eks(
      cluster_config_file,
      ami_json_file,
      add_cortex_node_groups: str,
      remove_eks_node_groups: str,
  ):
      cluster_config = yaml.safe_load(cluster_config_file)
      region = cluster_config["region"]
      name = cluster_config["cluster_name"]
      prometheus_instance_type = cluster_config[
          "prometheus_instance_type"
      ]
      ami_map = json.load(ami_json_file)[K8S_VERSION][region]
  
      eks = {
          "apiVersion": "eksctl.io/v1alpha5",
          "kind": "ClusterConfig",
          "metadata": {
              "name": name,
              "region": region,
              "version": K8S_VERSION,
          },
      }
  
      if add_cortex_node_groups:
          node_group_names = add_cortex_node_groups.split(",")
          eks["nodeGroups"] = []
          for node_group_name in node_group_names:
              nodegroup_config = get_nodegroup_config_by_name(
                  cluster_config, node_group_name
              )
              eks["nodeGroups"].append(
                  get_worker_nodegroup(
                      ami_map, nodegroup_config, cluster_config
                  )
              )
          click.echo(
              yaml.dump(
                  eks,
                  Dumper=IgnoreAliases,
                  default_flow_style=False,
                  default_style="",
              )
          )
          return
  
      if remove_eks_node_groups:
          stacks_names = remove_eks_node_groups.split(",")
          eks["nodeGroups"] = []
          for stack_name in stacks_names:
              eks["nodeGroups"].append(
                  get_empty_eks_nodegroup(stack_name)
              )
          click.echo(
              yaml.dump(
                  eks,
                  Dumper=IgnoreAliases,
                  default_flow_style=False,
                  default_style="",
              )
          )
          return
  
      operator_nodegroup = default_nodegroup(cluster_config)
      operator_settings = {
          "ami": get_ami(ami_map, "t3.medium"),
          "name": "cx-operator",
          "instanceType": "t3.medium",
          "minSize": 2,
          "maxSize": 25,
          "desiredCapacity": 2,
          "volumeType": "gp3",
          "volumeSize": 20,
          "volumeIOPS": 3000,
          "volumeThroughput": 125,
          "labels": {"operator": "true"},
      }
      operator_nodegroup = merge_override(
          operator_nodegroup, operator_settings
      )
  
      prometheus_nodegroup = default_nodegroup(cluster_config)
      prometheus_settings = {
          "ami": get_ami(ami_map, prometheus_instance_type),
          "name": "cx-prometheus",
          "instanceType": prometheus_instance_type,
          "minSize": 1,
          "maxSize": 1,
          "desiredCapacity": 1,
          "volumeType": "gp3",
          "volumeSize": 20,
          "volumeIOPS": 3000,
          "volumeThroughput": 125,
          "labels": {"prometheus": "true"},
          "taints": [
              {
                  "key": "prometheus",
                  "value": "true",
                  "effect": "NoSchedule",
              },
          ],
      }
      prometheus_nodegroup = merge_override(
          prometheus_nodegroup, prometheus_settings
      )
  
      worker_nodegroups = get_all_worker_nodegroups(
          ami_map, cluster_config
      )
  
      nat_gateway = "Disable"
      if cluster_config["nat_gateway"] == "single":
          nat_gateway = "Single"
      elif cluster_config["nat_gateway"] == "highly_available":
          nat_gateway = "HighlyAvailable"
  
      eks = {
          "apiVersion": "eksctl.io/v1alpha5",
          "kind": "ClusterConfig",
          "metadata": {
              "name": name,
              "region": region,
              "version": K8S_VERSION,
              "tags": cluster_config["tags"],
          },
          "vpc": {"nat": {"gateway": nat_gateway}},
          "nodeGroups": [operator_nodegroup, prometheus_nodegroup]
          + worker_nodegroups,
          "addons": [
              {
                  "name": "vpc-cni",
                  "version": "1.11.3",
              },
          ],
      }
  
      if (
          len(cluster_config.get("availability_zones", [])) > 0
          and len(cluster_config.get("subnets", [])) == 0
      ):
          eks["availabilityZones"] = cluster_config[
              "availability_zones"
          ]
  
      if len(cluster_config.get("subnets", [])) > 0:
          eks_subnet_configs = {}
          for subnet_config in cluster_config["subnets"]:
              eks_subnet_configs[subnet_config["availability_zone"]] = {
                  "id": subnet_config["subnet_id"]
              }
  
          if (
              cluster_config.get("subnet_visibility", "public")
              == "private"
          ):
              eks["vpc"]["subnets"] = {"private": eks_subnet_configs}
          else:
              eks["vpc"]["subnets"] = {"public": eks_subnet_configs}
  
      if cluster_config.get("vpc_cidr", "") != "":
          eks["vpc"]["cidr"] = cluster_config["vpc_cidr"]
  
      click.echo(
          yaml.dump(
              eks,
              Dumper=IgnoreAliases,
              default_flow_style=False,
              default_style="",
          )
      )
  
imports: import json
  import click
  from collections import namedtuple
  import re
  import yaml
label_desc: Use image node_id 18 for calling a global function with example usage: generate_eks(cluster_config_file, ami_json_file, add_cortex_node_groups, remove_eks_node_groups) without return types