This tutorial walks you through connecting Anaconda Platform to Amazon Bedrock so you can run text generation tasks from your workstations and Metaflow flows.
By the end of this tutorial, you will have:
- An IAM role that allows Anaconda Platform to interact with Bedrock
- A workstation notebook that lists available models and runs text generation
- A Metaflow flow that invokes a Bedrock model
Create Bedrock resources
AWS Bedrock requires an IAM role with permissions to invoke foundation models, and access to the models you want to use. For the full setup guide, see the AWS Bedrock getting started documentation.
Create an IAM role with permissions to invoke Bedrock models. Request access to the foundation models you plan to use in the Bedrock console.
To allow Anaconda Platform tasks to use your Bedrock role, register it as an integration in the platform:
-
Select Integrations in the left-hand navigation.
-
Click AWS in the Add an Integration section.
-
Enter a name for the integration.
-
Enter a description for the integration.
-
Enter the ARN of the IAM role you created.
If you need the ARN, expand the Getting your IAM role ARN section in the panel.This shows the trust policy statement you need to add to your role, and the tag key and value required for the platform to discover it. You can choose to use an existing target role or create a new one—the panel shows the required trust policy and tagging steps for either path.
-
Click Add.
After the integration is created, the How to use tab in the integration panel shows a code snippet with the exact role_arn value for your flows. Copy this snippet into your Metaflow steps to access Bedrock through the chained role.
Download the tutorial content
Download the tutorial content to your workstation:
The Bedrock tutorial content is in ~/learn/bedrock. If you prefer a different location, replace ~/learn with a directory of your choice.
This command downloads all tutorial content as a single bundle. If you’ve already worked through other tutorials, you likely already have this and do not need to run the command again.
Generate text from a workstation notebook
Open the notebook in 00-nb from the ~/learn/bedrock directory. Before running it, update the role_arn variable with the IAM role you created earlier. This notebook walks you through listing available Bedrock models and running text generation tasks.
Generate text from a Metaflow flow
Open the 01-flow directory from the ~/learn/bedrock directory. This directory contains a Metaflow flow that invokes a Bedrock model. Before running it, update the MY_BEDROCK_ROLE variable in flow.py with the same role ARN you used in the notebook.
Run the flow:
Next steps
To build on this tutorial:
- Explore other Bedrock model providers and capabilities.
- Build more complex workflows combining Bedrock with other AWS services.
- Integrate Bedrock into your existing ML pipelines.