Create a flow in Amazon Bedrock - Amazon Bedrock

Create a flow in Amazon Bedrock

To create a flow, you minimally provide a name and description for the flow and specify a service role with the proper permissions (or let the Amazon Bedrock console automatically create one for you). You will then define the flow by configuring nodes, which act as steps in the flow, and connections between the nodes. Before creating a flow, we recommend that you read How Amazon Bedrock Flows works to familiarize yourself with concepts and terms in Amazon Bedrock Flows and to learn about the types of nodes that are available to you. To learn how to create a flow select the tab corresponding to your method of choice and follow the steps:

Console
To create a flow
  1. Sign in to the AWS Management Console using an IAM role with Amazon Bedrock permissions, and open the Amazon Bedrock console at Getting Started with the AWS Management Console.

  2. Select Amazon Bedrock Flows from the left navigation pane.

  3. In the Amazon Bedrock Flows section, choose Create flow.

  4. Enter a Name for the flow and an optional Description.

  5. For the Service role name, choose one of the following options:

  6. (Optional) To encrypt your flow with a KMS key, select Customize encryption settings (advanced) and choose the key. For more information, see Key policy to allow Amazon Bedrock to encrypt and decrypt a flow.

  7. Choose Create. Your flow is created and you will be taken to the flow builder where you can build your flow.

  8. You can continue to the following procedure to build your flow or return to the flow builder later.

To build your flow
  1. If you're not already in the flow builder, do the following:

    1. Sign in to the AWS Management Console using an IAM role with Amazon Bedrock permissions, and open the Amazon Bedrock console at Getting Started with the AWS Management Console.

    2. Select Amazon Bedrock Flows from the left navigation pane. Then, choose a flow in the Amazon Bedrock Flows section.

    3. Choose Edit in flow builder.

  2. In the flow builder section, the center pane displays a Flow input node and a Flow output node. These are the input and output nodes for your flow.

  3. To add and configure nodes

    1. In the Flow builder pane, select Nodes.

    2. Drag a node you want to use for the first step of your flow and drop it in the center pane.

    3. The circles on the nodes are connection points. To connect your flow input node to the second node, drag a line from the circle on the Flow input node to the circle in the Input section of the node you just added.

    4. Select the node you just added.

    5. In the Configure section of the Flow builder pane, provide the configurations for the selected node and define names, data types, and expressions for the inputs and outputs of the node.

    6. In the Flow builder pane, select Nodes.

    7. Repeat steps to add and configure nodes the remaining nodes in your flow.

      Note

      If you use a service role that Amazon Bedrock automatically created for you, the role will update with the proper permissions as you add nodes. If you use a custom service role however, you must add the proper permissions to the policy attached to your service role by referring to Create a service role for Amazon Bedrock Flows in Amazon Bedrock.

  4. Connect the Output of the last node in your flow with the Input of the Flow output node. You can have multiple Flow output nodes. To add additional flow output nodes, drag the Flow output node and drop it next to the node where you want the flow to stop. Make sure to draw connections between the two nodes.

  5. You can either continue to the next procedure to Test a flow in Amazon Bedrock or come back later. To continue to the next step, choose Save. To come back later, choose Save and exit.

Delete a node or a connection

During the process of building your flow, you might need to delete a node or remove node connections.

To delete a node
  1. Select a node you want to delete.

  2. In the Flow builder pane, choose the delete icon ( Trapezoid-shaped diagram showing data flow from source to destination through AWS Transfer Family. ).

    Note

    If you use a service role that Amazon Bedrock automatically created for you, the role will update with the proper permissions as you add nodes. If you delete nodes, however, the relevant permissions won't be deleted. We recommend that you delete the permissions that you no longer need by following the steps at Modifying a role.

To remove a connection
  • In the Flow builder page, hover over the connection you want to remove until you see the expand icon and then drag the connection away from the node.

API

To create a flow, send a CreateFlow request (see link for request and response formats and field details) with an Agents for Amazon Bedrock build-time endpoint.

The following fields are required:

Field Basic description
name A name for the flow.
executionRoleArn The ARN of the service role with permissions to create and manage flows.

The following fields are optional:

Field Use case
definition Contains the nodes and connections that make up the flow.
description To describe the flow.
tags To associate tags with the flow. For more information, see Tagging Amazon Bedrock resources.
customerEncryptionKeyArn To encrypt the resource with a KMS key. For more information, see Key policy to allow Amazon Bedrock to encrypt and decrypt a flow.
clientToken To ensure the API request completes only once. For more information, see Ensuring idempotency.

While the definition field is optional, it is required for the flow to be functional. You can choose to create a flow without the definition first and instead update the flow later.

For each node in your nodes list, you specify the type of node in the type field and provide the corresponding configuration of the node in the config field. For details about the API structure of different types of nodes, see Node types in flow.

The following requirements apply to building a flow:

  • Your flow must have only one flow input node and at least one flow output node.

  • You can't include inputs for a flow input node.

  • You can't include outputs for a flow output node.

  • Every output in a node must be connected to an input in a downstream node (in the API, this is done through a FlowConnection with a FlowDataConnectionConfiguration).

  • Every condition (including the default one) in a condition node must be connected to a downstream node (in the API, this is done through a FlowConnection with a FlowConditionalConnectionConfiguration).

The following pointers apply to building a flow:

  • Begin by setting the data type for the output of the flow input node. This data type should match what you expect to send as the input when you invoke the flow.

  • When you define the inputs for a flow using expressions, check that the result matches the data type that you choose for the input.

  • If you include an iterator node, include a collector node downstream after you've sent the output through the nodes that you need. The collector node will return the outputs in an array.