def create_gcp_project()

in solutions_builder/copier_extensions/sb_helpers.py [0:0]


def create_gcp_project(project_id):
  """
    Get GCP project number based on project_id using gcloud command.
    """
  print_indent(f"(Creating GCP project '{project_id}'...)")
  try:
    # Create account.
    command = f"gcloud projects create {project_id}"
    exec_gcloud_output(command)

    # Link billing account.
    billing_account = get_current_billing_account()
    command = f"gcloud beta billing projects link {project_id} --billing-account={billing_account}"
    exec_gcloud_output(command)

  except subprocess.CalledProcessError as e:
    print_indent(f"{e.output}")
    print_indent(
      f"Unable to create GCP project '{project_id}'.\n")