<@ULVA73B9P> I’m creating an event-based deploymen...
# ask-marvin
l
@Marvin I’m creating an event-based deployment trigger in
prefect.yaml
and need to pass a field from the event payload (e.g.,
event.payload.output_uri
) as a parameter to the RunDeployment action. In the UI, Prefect represents this as a dict with
__prefect_kind: "jinja"
and a
template
key. The Prefect docs show how to configure this in the UI but don’t show the corresponding YAML syntax. What is the correct way to write this templated parameter in
prefect.yaml
so that Prefect interprets it as a Jinja template at runtime?
m
thought for 190.5 seconds
Short answer: wrap the parameter value as a Jinja placeholder object:
Copy code
parameters:
  output_uri:
    __prefect_kind: jinja
    template: "{{ event.payload.output_uri }}"
Details and examples (Prefect 3.x): - In a deployment’s event trigger inside prefect.yaml
Copy code
deployments:
  - name: my-deployment
    entrypoint: flows.py:my_flow
    work_pool:
      name: default
    triggers:
      - type: event
        enabled: true
        match:
          prefect.resource.id: my.app.resource
        expect:
          - my.event.type
        parameters:
          output_uri:
            __prefect_kind: jinja
            template: "{{ event.payload.output_uri }}"
          # static parameter (no templating)
          mode: "fast"
- If you are defining a top-level automation with a RunDeployment action, the same parameter wrapper goes under the action’s parameters:
Copy code
automations:
  - name: run-on-event
    trigger:
      type: event
      match:
        prefect.resource.id: my.app.resource
      expect:
        - my.event.type
    actions:
      - type: run-deployment
        deployment: "my-flow/my-deployment"
        parameters:
          output_uri:
            __prefect_kind: jinja
            template: "{{ event.payload.output_uri }}"
Notes: - Always include
__prefect_kind: jinja
with a
template
key; without it, Prefect treats the value as a literal. - If you want the result to be a structured object (e.g., pass the entire payload as a dict), use a JSON wrapper so the rendered template is parsed back into a Python object:
Copy code
parameters:
  full_payload:
    __prefect_kind: json
    value:
      __prefect_kind: jinja
      template: "{{ event.payload | tojson }}"
If you share a snippet of your prefect.yaml, I can sanity-check the placement and syntax.
l
@Marvin I tried this but didn't work: triggers: - type: event enabled: true match: prefect.resource.id: "flow-run.*" expect: - maps.decompress.completed threshold: 1 within: "PT1S" parameters: grib_file: template: "{{ event.payload.output_uri }}" __prefect_kind: jinja
m
thought for 155.3 seconds
Your YAML shape for templated parameters is correct, but there are a few common gotchas that can make it look like “it didn’t work.” What you wrote (explicit Jinja object) is valid:
Copy code
parameters:
  grib_file:
    __prefect_kind: jinja
    template: "{{ event.payload.output_uri }}"
You can also use the simpler string form (also supported):
Copy code
parameters:
  grib_file: "{{ event.payload.output_uri }}"
If it’s still not working, check these points: - Verify the event actually has payload.output_uri - Add a temporary debug parameter to inspect what the automation sees:
Copy code
parameters:
      grib_file: "{{ event.payload.output_uri }}"
      _debug_event:
        __prefect_kind: jinja
        template: "{{ event | tojson }}"
Then look at the automation firing in the UI and confirm the payload shape. - Ensure your match selector is correct - Flow run resource IDs look like
prefect.flow-run.<UUID>
. If you want to match flow-run events broadly, use either:
Copy code
match:
      prefect.resource.role: "flow-run"
or
Copy code
match:
      prefect.resource.id: "prefect.flow-run.*"
Using
flow-run.*
without the
prefect.
prefix typically won’t match. - Confirm the event type and payload source -
maps.decompress.completed
must be emitted with
payload={"output_uri": ...}
. If the event was not emitted with that payload key, the template will render empty/undefined. - Make sure your flow parameter name matches exactly - Your flow must accept a
grib_file
parameter; otherwise the parameter may be ignored or cause an error. - Re-deploy after changing prefect.yaml - Edit →
prefect deploy
again so the updated trigger and parameters are applied. - You can also try the “JSON wrapper” if you need a dict object (not needed for a single string, but useful for debugging):
Copy code
parameters:
    full_payload:
      __prefect_kind: json
      value:
        __prefect_kind: jinja
        template: "{{ event.payload | tojson }}"
If you can share: - a sample event (or the
_debug_event
output), - your exact
match
selector, - and the flow signature, I can pinpoint why the value isn’t rendering and suggest the minimal change.