Nils
01/29/2025, 3:28 PMMarvin
01/29/2025, 3:28 PMprefect.yaml
file using the syntax {{ prefect.blocks.block_type.block_slug }}
. This is particularly useful for including sensitive information, like credentials, without hardcoding them in plaintext.
For more detailed information, you can refer to the Prefect documentation on prefect.yaml.Nils
01/29/2025, 3:29 PMMarvin
01/29/2025, 3:29 PMenvironment variables
section of job variables within your prefect.yaml
file. You can use the syntax {{ prefect.blocks.block_type.block_slug }}
to include these references. This allows you to dynamically set environment variables using values stored in Prefect blocks, which is particularly useful for sensitive information.
For more details, refer to the Prefect documentation on prefect.yaml.Nils
01/29/2025, 3:29 PMMarvin
01/29/2025, 3:29 PMenvironment variables
section of a prefect.yaml
file:
yaml
version: 1
build:
- prefect.builds.steps.set_working_directory:
directory: /path/to/your/repo
deploy:
- prefect.deployments.steps.upload_to_storage:
storage_block: my-s3-bucket
infrastructure:
- prefect.infrastructure.process:
env:
MY_SECRET: "{{ prefect.blocks.secret.my_secret_block }}"
In this example, the MY_SECRET
environment variable is set using a value from a Prefect block of type secret
with the slug my_secret_block
. This ensures that the secret value is used securely without hardcoding it in the YAML file. Adjust the block type and slug to match your specific use case.Nils
01/29/2025, 3:31 PMMarvin
01/29/2025, 3:31 PMprefect.yaml
, you can use dot notation to reference the key within the block. Here's an example:
yaml
version: 1
build:
- prefect.builds.steps.set_working_directory:
directory: /path/to/your/repo
deploy:
- prefect.deployments.steps.upload_to_storage:
storage_block: my-s3-bucket
infrastructure:
- prefect.infrastructure.process:
env:
MY_SECRET_KEY: "{{ prefect.blocks.secret.my_secret_block.key_name }}"
In this example:
- my_secret_block
is the slug of your secret block.
- key_name
is the specific key within the secret block that you want to reference.
Ensure that the block and key names match those defined in your Prefect setup. This approach allows you to securely access just the necessary part of your secret configuration.Nils
01/29/2025, 3:34 PMMarvin
01/29/2025, 3:34 PMprefect.yaml
if you have a JSON block:
yaml
version: 1
infrastructure:
- prefect.infrastructure.process:
env:
MY_SECRET_KEY: "{{ prefect.blocks.json.my_secret_block.key_name }}"
Make sure that:
- my_secret_block
is the correct slug of your JSON block.
- key_name
is the exact key within the JSON structure.
If you continue to face issues, you might want to check the content of your block in the Prefect UI to ensure it matches the expected structure. For more detailed guidance, you can follow the GitHub pull request that introduced this feature.