Integrations also contain pre-built tasks and flows that can be imported and called within your code.
As an example, to read a secret from AWS Secrets Manager with the read_secret task:
fromprefectimportflowfromprefect_awsimportAwsCredentialsfromprefect_aws.secrets_managerimportread_secret@flowdefconnect_to_database():aws_credentials=AwsCredentials.load("MY_BLOCK_NAME")secret_value=read_secret(secret_name="db_password",aws_credentials=aws_credentials)# Use secret_value to connect to a database
To customize the settings of a task or flow pre-configured in a collection, use with_options:
fromprefectimportflowfromprefect_dbt.cloudimportDbtCloudCredentialsfromprefect_dbt.cloud.jobsimporttrigger_dbt_cloud_job_run_and_wait_for_completioncustom_run_dbt_cloud_job=trigger_dbt_cloud_job_run_and_wait_for_completion.with_options(name="Run My DBT Cloud Job",retries=2,retry_delay_seconds=10)@flowdefrun_dbt_job_flow():run_result=custom_run_dbt_cloud_job(dbt_cloud_credentials=DbtCloudCredentials.load("my-dbt-cloud-credentials"),job_id=1)run_dbt_job_flow()
To learn more about how to use Integrations, check out Prefect recipes on GitHub. These recipes provide examples of how Integrations can be used in various scenarios.