code: def connect_data(
      name: str,
      region: str,
      source: str,
      secret_arn_name: str = "",
      destination: str = "",
      project_name: str = "",
  ) -> None:
      """Create a new data connection."""
  
      from lightning_cloud.openapi import Create, V1AwsDataConnection
  
      if sys.platform == "win32":
          _error_and_exit(
              "Data connection isn't supported on windows. Open an issue on Github."
          )
  
      with Live(
          Spinner("point", text=Text("pending...", style="white")),
          transient=True,
      ) as live:
          live.stop()
  
          client = LightningClient(retry=False)
          projects = client.projects_service_list_memberships()
  
          project_id = None
  
          for project in projects.memberships:
              if project.name == project_name:
                  project_id = project.project_id
                  break
  
          if project_id is None:
              project_id = _get_project(client).project_id
  
          if not source.startswith("s3://"):
              return _error_and_exit(
                  "Only public S3 folders are supported for now. Please, open a Github issue with your use case."
              )
  
          try:
              client.data_connection_service_create_data_connection(
                  body=Create(
                      name=name,
                      aws=V1AwsDataConnection(
                          region=region,
                          source=source,
                          destination=destination,
                          secret_arn_name=secret_arn_name,
                      ),
                  ),
                  project_id=project_id,
              )
  
              # Note: Expose through lightning show data {DATA_NAME}
              # response = client.data_connection_service_list_data_connection_artifacts(
              #     project_id=project_id,
              #     id=response.id,
              # )
          except lightning_cloud.openapi.rest.ApiException as e:
              message = ast.literal_eval(e.body.decode("utf-8"))[
                  "message"
              ]
              _error_and_exit(
                  f"The data connection creation failed. Message: {message}"
              )
  
      rich.print(
          f"[green]Succeeded[/green]: You have created a new data connection {name}."
      )
      return None
  
file_path: pytorch-lightning/src/lightning/app/cli/connect/data.py
imports: import ast
  import sys
  import click
  import lightning_cloud
  import rich
  from rich.live import Live
  from rich.spinner import Spinner
  from rich.text import Text
  from lightning.app.utilities.app_helpers import Logger
  from lightning.app.utilities.cli_helpers import _error_and_exit
  from lightning.app.utilities.cloud import _get_project
  from lightning.app.utilities.network import LightningClient
label_desc: Use image node_id 1 for calling a global function with example usage: connect_data(name, region, source, secret_arn_name, destination, project_name) and returns: None, _error_and_exit