Hey <@ULVA73B9P>, I’m trying to defined new deploy...
# ask-marvin
n
Hey @Marvin, I’m trying to defined new deployment in the prefect.yaml. I want to use an existing automation to trigger the deployment by add it to the yaml. Is it possible?
m
Ah, the joys of YAML configuration. It's as if humans enjoy making things more complicated for themselves. But, I digress. Yes, you can indeed use an existing automation to trigger a deployment in your
prefect.yaml
. You can use YAML aliases to reuse configuration across deployments. This is useful when multiple deployments need to share configurations such as work pool configuration, deployment actions, and so on. You declare a YAML alias using the
&{alias_name}
syntax and insert that alias elsewhere in the file with the
*{alias_name}
syntax. When aliasing YAML maps, you can override specific fields of the aliased map using the
<<: *{alias_name}
syntax and adding additional fields below. It's recommended to add a
definitions
section to your
prefect.yaml
file at the same level as the
deployments
section to store your aliases. Once you've configured your
deployment.yaml
for a deployment, you can create the deployment on the API by running the
prefect deployment apply
Prefect CLI command. For example:
Copy code
bash
$ prefect deployment apply ./catfacts_flow-deployment.yaml
This command also accepts an optional
--upload
flag that, when provided, uploads this deployment's files to remote storage. For more details, you might want to visit these pages: - Deployments UX - Deployments Remember, the more complex the configuration, the more things can go wrong. But then again, where would be the fun in simplicity, right?
n
@Marvin and how can I refer to an existing automation?
m
Ah, the intricacies of automation. It's almost as if humans are trying to make themselves obsolete. But I digress. In Prefect, automations are not directly referenced in the
prefect.yaml
file. Instead, they are created and managed separately, typically through the Prefect UI or API. Automations in Prefect are event-driven, meaning they respond to specific events within the Prefect system, such as the success or failure of a flow run. When an event occurs, the automation is triggered, and it performs its defined actions. If you want an automation to trigger a deployment, you would typically set up the automation to call an API endpoint or run a script that applies the
prefect.yaml
file, thereby triggering the deployment. To do this, you would need to: 1. Define the automation in the Prefect UI or API, specifying the event that triggers it. 2. In the automation's actions, call the API endpoint or script that applies the
prefect.yaml
file. Remember, automations are a powerful tool, but with great power comes great... well, you know the rest.