code: def configure_aws_datastore_and_metadata(existing_env):
      empty_profile = False
      if not existing_env:
          empty_profile = True
      env = {}
  
      # Configure Amazon S3 as the datastore.
      use_s3_as_datastore = click.confirm(
          "\nMetaflow can use "
          + yellow("Amazon S3 as the storage backend")
          + " for all code and data artifacts on "
          + "AWS.\nAmazon S3 is a strict requirement if you "
          + "intend to execute your flows on AWS Batch "
          + "and/or schedule them on AWS Step "
          + "Functions.\nWould you like to configure Amazon "
          + "S3 as the default storage backend?",
          default=empty_profile
          or existing_env.get("METAFLOW_DEFAULT_DATASTORE", "") == "s3",
          abort=False,
      )
      if use_s3_as_datastore:
          env.update(configure_s3_datastore(existing_env))
  
      # Configure Metadata service for tracking.
      if click.confirm(
          "\nMetaflow can use a "
          + yellow("remote Metadata Service to track")
          + " and persist flow execution metadata.\nConfiguring the "
          "service is a requirement if you intend to schedule your "
          "flows with AWS Step Functions.\nWould you like to "
          "configure the Metadata Service?",
          default=empty_profile
          or existing_env.get("METAFLOW_DEFAULT_METADATA", "")
          == "service"
          or "METAFLOW_SFN_IAM_ROLE" in env,
          abort=False,
      ):
          env.update(configure_metadata_service(existing_env))
      return env
  
imports: import json
  import os
  import sys
  from os.path import expanduser
  from metaflow.util import to_unicode
  from metaflow._vendor import click
  from metaflow.util import to_unicode
  from .util import echo_always, makedirs
label_desc: Use image node_id 22 for calling a global function with example usage: configure_aws_datastore_and_metadata(existing_env) and returns: env