Google Cloud 콘솔을 사용하여 워크플로 만들기

이 빠른 시작에서는 Google Cloud 콘솔을 사용하여 첫 번째 워크플로를 만들고 배포, 실행하는 방법을 보여줍니다. 샘플 워크플로는 요청을 공개 API에 전송한 후 API 응답을 반환합니다.


Google Cloud 콘솔에서 이 태스크에 대한 단계별 안내를 직접 수행하려면 둘러보기를 클릭합니다.

둘러보기


시작하기 전에

조직에서 정의한 보안 제약조건으로 인해 다음 단계를 완료하지 못할 수 있습니다. 문제 해결 정보는 제한된 Google Cloud 환경에서 애플리케이션 개발을 참조하세요.

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. 이 가이드에 기존 프로젝트를 사용하는 경우 이 가이드를 완료하는 데 필요한 권한이 있는지 확인합니다. 새 프로젝트를 만든 경우 필요한 권한이 이미 있습니다.

  4. Verify that billing is enabled for your Google Cloud project.

  5. Enable the Workflows API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  7. 이 가이드에 기존 프로젝트를 사용하는 경우 이 가이드를 완료하는 데 필요한 권한이 있는지 확인합니다. 새 프로젝트를 만든 경우 필요한 권한이 이미 있습니다.

  8. Verify that billing is enabled for your Google Cloud project.

  9. Enable the Workflows API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  10. 인증을 설정합니다.
    1. Ensure that you have the Create Service Accounts IAM role (roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles.
    2. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    3. Select your project.
    4. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    5. Click Create and continue.
    6. Grant the Logging > Logs Writer role to the service account.

      To grant the role, find the Select a role list, then select Logging > Logs Writer.

    7. Click Continue.
    8. Click Done to finish creating the service account.

  11. 서비스 계정 역할 및 권한에 대한 자세한 내용은 Google Cloud 리소스에 액세스할 수 있도록 워크플로 권한 부여를 참고하세요.

필요한 역할

빠른 시작을 완료하는 데 필요한 권한을 얻으려면 관리자에게 프로젝트에 대한 다음 IAM 역할을 부여해 달라고 요청하세요.

역할 부여에 대한 자세한 내용은 프로젝트, 폴더, 조직에 대한 액세스 관리를 참조하세요.

커스텀 역할이나 다른 사전 정의된 역할을 통해 필요한 권한을 얻을 수도 있습니다.

워크플로 생성 및 배포

  1. Google Cloud 콘솔에서 Workflows 페이지로 이동합니다.

    Workflows로 이동

  2. 워크플로 페이지에서 만들기를 클릭합니다.

  3. 새 워크플로의 이름을 입력합니다(예: myFirstWorkflow).

  4. 리전으로 us-central1을 선택합니다.

  5. 서비스 계정에서 이전에 만든 서비스 계정을 선택합니다.

  6. 다음을 선택합니다.

  7. 워크플로 편집기에서 다음 워크플로를 복사하여 붙여넣습니다.

    YAML

    main:
      params: [input]
      steps:
        - checkSearchTermInInput:
            switch:
              - condition: '${"searchTerm" in input}'
                assign:
                  - searchTerm: '${input.searchTerm}'
                next: readWikipedia
        - getLocation:
            call: sys.get_env
            args:
              name: GOOGLE_CLOUD_LOCATION
            result: location
        - setFromCallResult:
            assign:
              - searchTerm: '${text.split(location, "-")[0]}'
        - readWikipedia:
            call: http.get
            args:
              url: 'https://en.wikipedia.org/w/api.php'
              query:
                action: opensearch
                search: '${searchTerm}'
            result: wikiResult
        - returnOutput:
            return: '${wikiResult.body[1]}'

    JSON

    {
      "main": {
        "params": [
          "input"
        ],
        "steps": [
          {
            "checkSearchTermInInput": {
              "switch": [
                {
                  "condition": "${\"searchTerm\" in input}",
                  "assign": [
                    {
                      "searchTerm": "${input.searchTerm}"
                    }
                  ],
                  "next": "readWikipedia"
                }
              ]
            }
          },
          {
            "getLocation": {
              "call": "sys.get_env",
              "args": {
                "name": "GOOGLE_CLOUD_LOCATION"
              },
              "result": "location"
            }
          },
          {
            "setFromCallResult": {
              "assign": [
                {
                  "searchTerm": "${text.split(location, \"-\")[0]}"
                }
              ]
            }
          },
          {
            "readWikipedia": {
              "call": "http.get",
              "args": {
                "url": "https://en.wikipedia.org/w/api.php",
                "query": {
                  "action": "opensearch",
                  "search": "${searchTerm}"
                }
              },
              "result": "wikiResult"
            }
          },
          {
            "returnOutput": {
              "return": "${wikiResult.body[1]}"
            }
          }
        ]
      }
    }
    

    자체 검색어를 입력하지 않는 한 이 워크플로는Google Cloud 위치를 사용하여 검색어를 구성하며 이는 Wikipedia API로 전달됩니다. 관련 Wikipedia 자료 목록이 반환됩니다.

  8. 배포를 선택합니다.

워크플로 실행

워크플로가 성공적으로 배포되면 처음으로 실행할 수 있습니다. 워크플로를 배포하면 워크플로 세부정보 페이지로 이동하게 됩니다.

  1. 워크플로 세부정보 페이지에서 실행을 클릭합니다.

  2. 워크플로 실행 페이지에서 실행을 클릭합니다.

  3. 출력 창에 워크플로 결과가 표시됩니다.

첫 번째 워크플로를 배포하고 실행했습니다.

삭제

이 페이지에서 사용한 리소스 비용이 Google Cloud 계정에 청구되지 않도록 하려면 다음 단계를 수행합니다.

  1. Google Cloud 콘솔에서 Workflows 페이지로 이동합니다.

    Workflows로 이동

  2. 워크플로 목록에서 워크플로를 클릭하여 워크플로 세부정보 페이지로 이동합니다.

  3. 삭제를 클릭합니다.

  4. 워크플로 이름을 입력한 다음 확인을 클릭합니다.

다음 단계