code: def bootstrap_aws(config):
      # create a copy of the input config to modify
      config = copy.deepcopy(config)
  
      # Log warnings if user included deprecated `head_node` or `worker_nodes`
      # fields. Raise error if no `available_node_types`
      check_legacy_fields(config)
      # Used internally to store head IAM role.
      config["head_node"] = {}
  
      # If a LaunchTemplate is provided, extract the necessary fields for the
      # config stages below.
      config = _configure_from_launch_template(config)
  
      # If NetworkInterfaces are provided, extract the necessary fields for the
      # config stages below.
      config = _configure_from_network_interfaces(config)
  
      # The head node needs to have an IAM role that allows it to create further
      # EC2 instances.
      config = _configure_iam_role(config)
  
      # Configure SSH access, using an existing key pair if possible.
      config = _configure_key_pair(config)
      global_event_system.execute_callback(
          CreateClusterEvent.ssh_keypair_downloaded,
          {"ssh_key_path": config["auth"]["ssh_private_key"]},
      )
  
      # Pick a reasonable subnet if not specified by the user.
      config = _configure_subnet(config)
  
      # Cluster workers should be in a security group that permits traffic within
      # the group, and also SSH access from outside.
      config = _configure_security_group(config)
  
      # Provide a helpful message for missing AMI.
      _check_ami(config)
  
      return config
  
imports: import copy
  import itertools
  import json
  import logging
  import os
  import time
  from collections import Counter
  from functools import lru_cache, partial
  from typing import Any, Dict, List, Optional, Set, Tuple
  import boto3
  import botocore
  from packaging.version import Version
  from ray.autoscaler._private.aws.cloudwatch.cloudwatch_helper import CloudwatchHelper
  from ray.autoscaler._private.aws.utils import LazyDefaultDict, handle_boto_error, resource_cache
  from ray.autoscaler._private.cli_logger import cf, cli_logger
  from ray.autoscaler._private.event_system import CreateClusterEvent, global_event_system
  from ray.autoscaler._private.providers import _PROVIDER_PRETTY_NAMES
  from ray.autoscaler._private.util import check_legacy_fields
  from ray.autoscaler.tags import NODE_TYPE_LEGACY_HEAD, NODE_TYPE_LEGACY_WORKER
label_desc: Use image node_id 7 for calling a global function with example usage: bootstrap_aws(config) and returns: config