Hi, I'm unable to create a deployment from a prefe...
# ask-community
i
Hi, I'm unable to create a deployment from a prefect.yaml. Am I missing something? I execute the following via CLI:
$ prefect deployment apply prefect.yaml
I get the following error:
'prefect.yaml' did not conform to deployment spec: AttributeError("'NoneType' object has no attribute 'name'")
Contents of the prefect.yaml.
Copy code
name: a_flow
prefect-version: 2.14.9

pull:
- prefect.deployments.steps.set_working_directory:
    directory: /app

definitions:
  tags: &common_tags
    - development
    - eks
  work_pool: &common_work_pool
    name: development-kubernetes
    job_variables:
      image: "{{ $PREFECT_IMAGE_NAME }}:$CIRCLE_SHA1"

deployments:
- name: default
  entrypoint: main.py:run_flow
  path: /app
  tags: *common_tags
  version: "{{ $CIRCLE_SHA1 }}"
  work_pool_name: *common_work_pool
a
Hey @Ian Thomas! The format that you’re using works with the
prefect deploy
CLI command. You can deploy your flow by running
prefect deploy
in the same directory as your file if you rename it to
prefect.yaml
.
i
That worked after I answered a few questions: I see it in Prefect Cloud. Thanks! Is
$ prefect deployment apply prefect.yaml
deprecated or no longer supported?
a
It is still supported but it uses a different format. We recommend using
prefect deploy
over
prefect deployment apply
because you can customize your pull steps and deploy multiple flows in a single command with
prefect deploy
.
i
Ah - got it. And if I want to drop this into a CICD pipeline and make it non-interactive, I should do the following? (assumes I've authenticated to Prefect Cloud before execution)
$ prefect --no-prompt deploy
a
Yep, exactly!
i
Awesome - thanks! I need to add in some additional settings to pass along to the Kubernetes Job that will execute this flow via our running Worker, like a secret ref and service account. From the documentation I've read, I should add those under the job_variables attribute?
a
If you want to add configuration to the Jobs that spin up for each flow, you’ll need to edit the base job template of your work pool. You can hard code things like your secret ref and service account, or use base job template variables to all those values to change on a per-deployment basis. You can specify values for any base job template variables in the
job_variables
section of a deployment config in
prefect.yaml
.
i
Perfect. I'll add those two items as variables to the base job template and populate them in the prefect.yaml from parsed Terragrunt JSON output. Thanks again!