Prerequisites
- Prefect installed
- Authenticated with Prefect Cloud (or self-hosted Prefect server instance)
- A cloud provider account
Install relevant Prefect integration library
In the CLI, install the Prefect integration library for your cloud provider:- AWS
- Azure
- GCP
prefect-aws provides blocks for interacting with AWS services.
Register the block types
Register the new block types with Prefect Cloud (or with your self-hosted Prefect server instance):- AWS
- Azure
- GCP
Create a storage bucket
Create a storage bucket in the cloud provider account. Ensure the bucket is publicly accessible, or create a user or service account with the appropriate permissions to fetch and write data to the bucket.Create a credentials block
If the bucket is private, there are several options to authenticate:- At deployment runtime, ensure the runtime environment is authenticated.
- Create a block with configuration details and reference it when creating the storage block.
- AWS
- Azure
- GCP
Create a storage block
You can create a block for the chosen cloud provider using Python code or the UI. This example uses Python code.- AWS
- Azure
- GCP
Note that the
S3Bucket block is not the same as the S3 block that ships with Prefect.
The S3Bucket block used in this example is part of the prefect-aws library and provides additional functionality.Next, reference the credentials block created above.Write data
Use your new block inside a flow to write data to your cloud provider.- AWS
- Azure
- GCP
Read data
Use your block to read data from your cloud provider inside a flow.- AWS
- Azure
- GCP
Next steps
Check out theprefect-aws, prefect-azure, and prefect-gcp docs to see additional methods for interacting with cloud storage providers.
Each library also contains blocks for interacting with other cloud-provider services.