Madushan Pathirana
10/23/2025, 6:56 AMMarvin
10/23/2025, 6:56 AMMarvin
10/23/2025, 7:09 AMenv values in your prefect.ecs.yaml configurable in Prefect 3.x. Below are the options and examples. First, two quick notes about your YAML:
- For ECS workers, work_pool.job_variables.env should be a dict (KEY: VALUE), which you’re already using — good.
- Your tags should be a list of strings (not a nested list) and the image line looks malformed. Also, push: false is not a valid job variable and should be removed from job_variables.
Ways to parameterize env for dev/stage/prod
1) Define multiple deployments in one file (works with --all)
- Best if you want prefect --no-prompt deploy --all --prefect-file prefect.ecs.yaml to create all envs at once.
Example:
# Generic metadata about this project
name: src
prefect-version: 3.4.11
build:
- prefect.deployments.steps.utility.run_shell_script:
id: git_sha
script: git rev-parse --short HEAD
- prefect_docker.deployments.steps.build_docker_image:
id: build_image
requires: prefect-docker>=0.3.1
image_name: <http://010614160260.dkr.ecr.ap-southeast-1.amazonaws.com/credilinq-prefect|010614160260.dkr.ecr.ap-southeast-1.amazonaws.com/credilinq-prefect>
tag: '{{ git_sha.stdout }}'
additional_tags:
- dev
dockerfile: Dockerfile.prefect_flows_run
ignore_cache: true
push:
- prefect_docker.deployments.steps.push_docker_image:
requires: prefect-docker>=0.3.1
image_name: '{{ build_image.image_name }}'
tag: '{{ git_sha.stdout }}'
additional_tags:
- dev
pull:
- prefect.deployments.steps.set_working_directory:
directory: /opt/prefect/src
deployments:
- name: dev
version: '{{ build_image.tag }}'
tags: ['dev']
entrypoint: extraction/ebay/flow.py:run
parameters:
seller_id: "d480fd76-f59e-4ea0-95cb-4e22db0164e0"
selling_partner_id: "ed442813-afe7-4026-bc14-190ca41bfb23"
data_cycle: "origination"
work_pool:
name: my-ecs-pool
work_queue_name: default
job_variables:
image: <http://010614160260.dkr.ecr.ap-southeast-1.amazonaws.com/credilinq-prefect:{{|010614160260.dkr.ecr.ap-southeast-1.amazonaws.com/credilinq-prefect:{{> git_sha.stdout }}
cpu: 4096
memory: 8192
env:
APP_ENV: "dev"
SOURCE: "ebay"
- name: stage
version: '{{ build_image.tag }}'
tags: ['stage']
entrypoint: extraction/ebay/flow.py:run
parameters:
seller_id: "d480fd76-f59e-4ea0-95cb-4e22db0164e0"
selling_partner_id: "ed442813-afe7-4026-bc14-190ca41bfb23"
data_cycle: "origination"
work_pool:
name: my-ecs-pool
work_queue_name: default
job_variables:
image: <http://010614160260.dkr.ecr.ap-southeast-1.amazonaws.com/credilinq-prefect:{{|010614160260.dkr.ecr.ap-southeast-1.amazonaws.com/credilinq-prefect:{{> git_sha.stdout }}
cpu: 4096
memory: 8192
env:
APP_ENV: "stage"
SOURCE: "ebay"
- name: prod
version: '{{ build_image.tag }}'
tags: ['prod']
entrypoint: extraction/ebay/flow.py:run
parameters:
seller_id: "d480fd76-f59e-4ea0-95cb-4e22db0164e0"
selling_partner_id: "ed442813-afe7-4026-bc14-190ca41bfb23"
data_cycle: "origination"
work_pool:
name: my-ecs-pool
work_queue_name: default
job_variables:
image: <http://010614160260.dkr.ecr.ap-southeast-1.amazonaws.com/credilinq-prefect:{{|010614160260.dkr.ecr.ap-southeast-1.amazonaws.com/credilinq-prefect:{{> git_sha.stdout }}
cpu: 4096
memory: 8192
env:
APP_ENV: "prod"
SOURCE: "ebay"
Then:
prefect --no-prompt deploy --all --prefect-file prefect.ecs.yaml
2) Use Prefect Variables in your YAML
- Define variables once and reference them in the YAML.
- Good if you want to change values without touching the repo.
YAML:
env:
APP_ENV: "{{ prefect.variables.app_env }}"
SOURCE: "{{ prefect.variables.source }}"
Set variables:
prefect variable set app_env dev
prefect variable set source ebay
Docs: Prefect Variables and prefect.yaml templatingMarvin
10/23/2025, 7:09 AMenv:
APP_ENV: "{{ $APP_ENV }}"
SOURCE: "{{ $SOURCE }}"
Deploy:
export APP_ENV=stage SOURCE=ebay
prefect --no-prompt deploy --all --prefect-file prefect.ecs.yaml
Docs: prefect.yaml (environment variable templating with {{ $VAR }})
4) CLI overrides with --job-variable (individual deployments only)
- Use this when deploying a single deployment (not with --all).
Examples:
prefect deploy --prefect-file prefect.ecs.yaml --name dev \
--job-variable env.APP_ENV=dev \
--job-variable env.SOURCE=ebay
# or short form
prefect deploy --prefect-file prefect.ecs.yaml -n dev \
-jv env.APP_ENV=stage -jv env.SOURCE=ebay
Note: --job-variable overrides do not apply when using --all. You must deploy a single deployment by name. Docs: Customize job variables
Common fixes to your current file
- Fix tags and image line; remove the stray push: false under job_variables.
- Quote templated expressions:
- image: <http://010614160260.dkr.ecr.ap-southeast-1.amazonaws.com/credilinq-prefect:{{|010614160260.dkr.ecr.ap-southeast-1.amazonaws.com/credilinq-prefect:{{> git_sha.stdout }}
- env values can be quoted: "{{ $APP_ENV }}", "{{ prefect.variables.app_env }}"
Questions for you
- Do you want to keep using --all to create dev/stage/prod in one go? If yes, I recommend option 1 (define three deployments in the same file).
- If you prefer a single deployment and change env per deploy, do you want to pass values via shell env (option 3) or via --job-variable flags (option 4)?
Relevant docs
- prefect.yaml templating: prefect.yaml
- Customize job variables (including CLI overrides): Customize job variables
- Prefect Variables: Prefect Variables