

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 흐름 실행을 통해 Amazon Bedrock 흐름을 비동기적으로 실행합니다.
<a name="flows-create-async"></a>

흐름 실행을 사용하면 Amazon Bedrock 흐름을 비동기적으로 실행할 수 있습니다. 이를 통해 흐름이 더 오래 실행될 수 있고 애플리케이션에서 다른 태스크를 수행할 수 있도록 제어할 수 있습니다.

Amazon Bedrock 콘솔을 사용하거나 [InvokeFlow](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeFlow.html) 작업을 사용하여 흐름을 실행하면 흐름이 완료되거나 한 시간에 시간 초과될 때까지(둘 중 먼저 도래하는 시점) 흐름이 실행됩니다. 흐름 실행을 실행하면 흐름이 훨씬 더 오래 실행될 수 있습니다. 개별 노드는 최대 5분 동안 실행되고 전체 흐름은 최대 24시간 동안 실행될 수 있습니다.

**참고**  
흐름 실행은 Amazon Bedrock의 미리 보기 릴리스이므로 변경될 수 있습니다.

## 흐름 실행을 실행하는 데 필요한 권한
<a name="flows-create-async-permissions"></a>
+ Amazon Bedrock Flows 서비스 역할에 필요한 모든 권한이 있는지 확인합니다. 자세한 내용은 [Amazon Bedrock에서 Amazon Bedrock Flows의 서비스 역할 생성](flows-permissions.md) 단원을 참조하십시오.
+ (선택 사항) 고객 관리형 AWS KMS 키를 사용하여 흐름 실행 데이터를 암호화합니다. 자세한 내용은 [Amazon Bedrock Flows 리소스 암호화](encryption-flows.md) 단원을 참조하십시오.

## 흐름 실행 생성 및 관리
<a name="flows-create-async-how-to"></a>

콘솔에서 또는 [StartFlowExecution](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_StartFlowExecution.html) 작업을 사용하여 흐름 실행을 생성할 수 있습니다.

------
#### [ Console ]

1. [Amazon Bedrock에서 흐름 생성 및 설계](flows-create.md)의 지침에 따라 흐름을 만듭니다.

1. [Amazon Bedrock에서 흐름의 별칭 생성](flows-alias-create.md)의 지침에 따라 흐름의 별칭을 생성합니다.

1. **흐름 빌더**가 아직 열려 있지 않은 경우 다음을 수행합니다.

   1. Amazon Bedrock 콘솔을 사용할 권한이 있는 IAM 자격 증명 AWS Management Console 으로에 로그인합니다. 그 다음 [https://console.aws.amazon.com/bedrock](https://console.aws.amazon.com/bedrock)에서 Amazon Bedrock 콘솔을 엽니다.

   1. 왼쪽 탐색 창에서 **Amazon Bedrock Flows**를 선택한 다음 흐름을 선택합니다.

1. **실행** 탭을 선택한 다음 **실행 생성**을 선택합니다.

1. **실행 생성** 대화 상자에 다음을 입력합니다.

   1. **이름**에 흐름 실행의 이름을 입력합니다.

   1. **별칭 선택**에서 사용하려는 흐름의 별칭을 선택합니다.

   1. **프롬프트 입력**에 흐름을 시작할 프롬프트를 입력합니다.

   1. **생성**을 선택하여 흐름 실행을 생성하고 실행을 시작합니다.

1. 흐름 세부 정보 페이지에서 **실행** 탭을 선택하고 **실행 상태**의 흐름 실행 상태를 기록해 둡니다.

1. (선택 사항) 실행을 선택하여 흐름을 열고 실행 요약을 확인합니다.

   **실행 출력**에는 흐름의 출력이 표시됩니다.

1. (선택 사항) 흐름 실행을 중지하려면 실행을 선택하고 **중지**를 선택합니다.

------
#### [ API ]

**흐름 실행 시작**  
흐름 실행을 실행하려면 [Amazon Bedrock Agents 런타임 엔드포인트](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#bra-rt)를 사용하여 [StartFlowExecution](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_StartFlowExecution.html) 요청을 전송합니다. 요청에서 실행하려는 흐름의 흐름 ID와 흐름 별칭 ID를 지정합니다. 다음을 지정할 수도 있습니다.
+ **입력** - 흐름 실행을 시작할 [입력](flows-nodes.md#flows-nodes-input) 노드가 포함된 배열입니다. `content` 필드의 프롬프트 흐름 입력 노드로 전송할 입력을 지정합니다.
+ **이름** - 흐름 실행의 이름입니다.

```
{
    "inputs": [{
        "nodeName": "FlowInputNode",
        "nodeOutputName": "document",
        "content": {
            "document": "Test"
        }
    }],
    "name": "MyExecution"
}
```

응답은 흐름 실행의 Amazon 리소스 이름(ARN)입니다. `executionArn`을 사용하여 흐름 실행이 완료되거나 조건 노드가 조건을 평가하는 경우와 같이 흐름의 현재 상태를 폴링할 수 있습니다.

```
{
      "executionArn": "arn:aws:bedrock:us-west-2:111122223333:flow/FLOWID/alias/TSTALIASID/execution/MyExecution"
}
```

**흐름 실행 진행 상황 추적**  
[GetFlowExecution](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_GetFlowExecution.html) 작업을 사용하여 실행 ARN으로 식별하는 흐름의 현재 상태를 가져옵니다. 흐름 상태는 `Running`, `Succeeded`, `Failed`, `TimedOut` 또는 `Aborted`입니다.

```
{
      "endedAt": null,
      "errors": null,
      "executionArn": "arn:aws:bedrock:us-west-2:111122223333:flow/FLOWID/alias/TSTALIASID/execution/MyExecution",
      "flowAliasIdentifier": "TSTALIASID",
      "flowIdentifier": "FLOWID",
      "flowVersion": "DRAFT",
      "startedAt": "2025-03-20T23:32:28.899221162Z",
      "status": "Running"
}
```

오류(예: 제한 시간이 초과된 Lambda 노드)는 다음 예제와 같이 `errors` 배열에 반환됩니다.

```
"errors": [{
    "nodeName": "LambdaNode1",
    "errorType": "ExecutionTimedOut",
    "message": "Call to lambda function timed out"
}],
```

**흐름 실행 결과 가져오기**  
Amazon Bedrock은 흐름의 출력을 흐름의 [출력](flows-nodes.md#flows-nodes-output) 노드에 씁니다. 흐름이 완료되거나 흐름이 실행되는 동안(사용 사례에 따라 다름) 출력을 가져올 수 있습니다.

흐름이 먼저 완료되도록 하려면 `GetFlowExecution`을 직접 호출하고 응답의 `status` 필드 값이 `Succeeded`인지 확인합니다.

흐름 실행에서 출력 이벤트 목록을 가져오려면 [ListFlowExecutionEvents](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_ListFlowExecutionEvents.html)를 직접 호출합니다. 응답에서 `flowExecutionEvents`의 `flowOutputEvent` 객체를 확인합니다. 예를 들어 `content` 필드에서 흐름의 출력을 가져올 수 있습니다.

```
{
      "flowOutputEvent": {
        "content": {
          "document": "The model response."
        },
        "nodeName": "FlowOutputNode"
      }
}
```

`eventType` 쿼리 파라미터를 `Flow`로 설정하여 `ListFlowExecutions`의 출력을 입력 및 출력 노드로만 제한할 수 있습니다.

**이벤트 보기**  
흐름 실행을 디버깅하기 위해 [ListFlowExecutionEvents](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_ListFlowExecutionEvents.html) 작업을 사용하여 흐름이 실행되는 동안 노드가 생성하는 이벤트를 볼 수 있습니다. 다음 예제와 유사한 응답에서 모든 노드(중간 노드 포함)의 입력 및 출력을 보려면 `eventType` 쿼리 파라미터를 `Node`로 설정합니다.

```
{
    "flowExecutionEvents": [{
            "nodeOutputEvent": {
                "fields": [{
                    "content": {
                        "document": "History book"
                    },
                    "name": "document"
                }],
                "nodeName": "FlowInputNode",
                "timestamp": "2025-05-05T18:38:56.637867516Z"
            }
        },
        {
            "nodeInputEvent": {
                "fields": [{
                    "content": {
                        "document": "History book"
                    },
                    "name": "book"
                }],
                "nodeName": "Prompt_1",
                "timestamp": "2025-05-05T18:38:57.434600163Z"
            }
        },
        {
            "nodeOutputEvent": {
                "fields": [{
                    "content": {
                        "document": "Here's a summary of the history book."
                    },
                    "name": "modelCompletion"
                }],
                "nodeName": "Prompt_1",
                "timestamp": "2025-05-05T18:39:06.034157077Z"
            }
        },
        {
            "nodeInputEvent": {
                "fields": [{
                    "content": {
                        "document": "Here's a summary of the history book."
                    },
                    "name": "document"
                }],
                "nodeName": "FlowOutputNode",
                "timestamp": "2025-05-05T18:39:06.453128251Z"
            }
        }
    ]
}
```

**흐름 실행의 스냅샷 가져오기**  
Amazon Bedrock은 흐름 실행이 시작될 때 흐름 정의 및 메타데이터의 스냅샷을 자동으로 생성합니다. 이는 흐름이 비동기적으로 실행되는 동안 흐름을 업데이트할 수 있기 때문에 유용합니다. 이 스냅샷을 검색하려면 [GetExecutionFlowSnapshot](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_GetExecutionFlowSnapshot.html) 작업을 직접 호출합니다. 응답에는 다음 흐름 필드가 포함됩니다.
+ **customerEncryptionKeyArn** - 흐름을 암호화하는 AWS KMS 키의 ARN입니다.
+ **정의** - 흐름의 [정의](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_FlowDefinition.html)입니다.
+ **executionRoleArn** - 흐름 실행에 사용되는 IAM 서비스 역할의 ARN입니다.
+ **flowAliasIdentifier** - 흐름의 별칭 ID입니다.
+ **flowIdentifier** - 흐름의 ID입니다.
+ **flowVersion** - 흐름의 버전입니다.

```
{
      "customerEncryptionKeyArn": null,
      "definition": "{flow-definition}",
      "executionRoleArn": "arn:aws:iam::111122223333:role/name",
      "flowAliasIdentifier": "TSTALIASID",
      "flowIdentifier": "FLOWID",
      "flowVersion": "DRAFT"
}
```

**흐름 실행 나열**  
[ListFlowExecutions](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_ListFlowExecutions.html) 작업을 직접 호출하여 흐름 실행 목록을 가져올 수 있습니다. 응답에는 흐름 또는 흐름 별칭에 대한 현재의 각 흐름 실행에 AWS 리전 대한 정보가 포함된 `flowExecutionSummaries` 배열이 포함됩니다. 각 요소에는 실행 ARN, 시작 시간, 흐름의 현재 상태와 같은 정보가 포함됩니다.

```
{
    "flowExecutionSummaries": [{
        "createdAt": "2025-03-11T23:21:02.875598966Z",
        "endedAt": null,
        "executionArn": "arn:aws:bedrock:us-west-2:111122223333:flow/FLOWID/alias/TSTALIASID/execution/MyExecution",
        "flowAliasIdentifier": "TSTALIASID",
        "flowIdentifier": "FLOWID",
        "flowVersion": "DRAFT",
        "status": "Running"
    }]
}
```

**실행 중인 흐름 실행 중지**  
실행 중인 흐름 실행을 중지해야 하는 경우 [StopFlowExecution](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_StopFlowExecution.html) 작업을 직접 호출하고 중지하려는 실행의 흐름 ID, 흐름 별칭 ID 및 흐름 실행 ID를 전달합니다.

------

## 흐름 실행 상태
<a name="flows-async-statuses"></a>

흐름 실행은 다음 상태 중 하나를 가질 수 있습니다.
+ **실행 중** - 흐름 실행이 진행 중입니다.
+ **성공 **- 흐름 실행이 성공적으로 완료되었습니다.
+ **실패** - 오류로 인해 흐름 실행이 실패했습니다.
+ **시간 초과** - 흐름 실행이 최대 런타임인 24시간을 초과했습니다.
+ **중단됨** - [StopFlowExecution](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_StopFlowExecution.html) 작업을 사용하여 흐름 실행이 수동으로 중지되었습니다.

더 이상 실행되지 않는 흐름 실행은 90일 후에 자동으로 삭제됩니다.

## 흐름 실행 모범 사례
<a name="flows-async-best-practices"></a>

흐름 실행을 사용할 때는 다음 사항을 고려하세요.
+ 흐름이 터미널 상태(`Running` 이외의 모든 상태)에 도달할 때까지 [GetFlowExecution](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_GetFlowExecution.html)을 사용하여 흐름 실행의 상태를 정기적으로 폴링합니다.
+ 흐름 실행이 터미널 상태에 도달하면 [ListFlowExecutionEvents](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_ListFlowExecutionEvents.html)를 사용하여 흐름 결과를 가져옵니다. 예를 들어 이러한 결과를 사용하여 흐름에 대한 몇 가지 로직을 구축할 수 있습니다.
+ [GetExecutionFlowSnapshot](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_GetExecutionFlowSnapshot.html)을 사용하여 흐름 실행의 스냅샷을 가져오면 실행과 관련된 문제가 발생할 경우 디버깅에 도움이 됩니다.