Ronald Sam
03/14/2025, 2:45 PMMarvin
03/14/2025, 2:45 PMRonald Sam
03/14/2025, 2:46 PMMarvin
03/14/2025, 2:46 PMAwsSecret
block. This block allows you to access secrets stored in AWS Secrets Manager.
- In the Prefect UI, navigate to the Blocks page, add a new block, and select AWS Secret from the list. Provide the secret name from AWS Secrets Manager.
2. Create an AWS Credentials Block:
- In the Prefect UI, add an AwsCredentials
block. Prefect will read the Access Key ID and Secret Access Key from your local ~/.aws/credentials
file, so you can leave those fields blank in the block configuration.
3. Accessing Secrets in a Flow:
- You can use the Secret
block in your flow to retrieve the secret value. Here's a simple example:
python
from prefect import flow
from prefect.blocks.system import Secret
@flow
def my_flow():
secret_value = Secret.load("my-secret").get()
print(secret_value)
4. Environment Variables:
- Prefect can also use environment variables to access AWS credentials, which can be set in your deployment environment.
For more detailed information, you can refer to the Prefect documentation on secrets.
This approach ensures that your AWS credentials are managed securely and are not exposed in your codebase.