<@ULVA73B9P> Can we have multiple deployments with...
# ask-marvin
r
@Marvin Can we have multiple deployments with the same name ? I have to create a deployment for each of my environments so deployments will have the tags that will be different but the same name
m
thought for 325.8 seconds
Short answer: Not for the same flow. In Prefect 3.x, deployment names must be unique per flow. The canonical identifier for a deployment is
<FLOW_NAME>/<DEPLOYMENT_NAME>
. You can reuse the same deployment name across different flows, but you cannot create two deployments with the same name for the same flow—even if the tags differ. Recommended pattern for per-environment deployments of the same flow: - Give each deployment a distinct name like
dev
,
staging
,
prod
- Use tags to annotate/filter (e.g.,
["env:dev"]
,
["env:prod"]
) - Point each deployment at the appropriate work pool or job variables for that environment Example
prefect.yaml
snippet:
Copy code
name: my-project
prefect-version: ">=3.0.0"

deployments:
  - name: dev
    entrypoint: flows/my_flow.py:my_flow
    tags: ["env:dev"]
    parameters:
      dry_run: true
    work_pool:
      name: dev-pool
      job_variables:
        env: DEV
        image: <http://ghcr.io/acme/my-flow:dev|ghcr.io/acme/my-flow:dev>

  - name: staging
    entrypoint: flows/my_flow.py:my_flow
    tags: ["env:staging"]
    work_pool:
      name: staging-pool
      job_variables:
        env: STAGING
        image: <http://ghcr.io/acme/my-flow:staging|ghcr.io/acme/my-flow:staging>

  - name: prod
    entrypoint: flows/my_flow.py:my_flow
    tags: ["env:prod"]
    work_pool:
      name: prod-pool
      job_variables:
        env: PROD
        image: <http://ghcr.io/acme/my-flow:prod|ghcr.io/acme/my-flow:prod>
Useful commands: - Create deployments from your project:
prefect deploy
(run from the project root) - List deployments:
prefect deployment ls
- Run a specific deployment:
prefect deployment run "my_flow/dev"
Notes: - Tags are great for filtering and automations, but workers pick up work based on work pools/queues and job settings, not tags. - CLI reference for deployment commands:
prefect deployment --help
and
prefect deployment run --help
(you’ll see the
<FLOW_NAME>/<DEPLOYMENT_NAME>
format). Docs: - Prefect YAML and multi-deployment setup: prefect.yaml how-to If you share your flow name and desired environments, I can draft a
prefect.yaml
that matches your setup.