<@ULVA73B9P> this deployment isnt runnable on pref...
# ask-marvin
s
@Marvin this deployment isnt runnable on prefect, says it’s deprecated: resource “prefect_deployment” “dist_alerts” { name = “DIST-data-update” work_pool_name = prefect_work_pool.ecs_pool.name flow_id = prefect_flow.dist_alerts_update.id path = “./” # version = var.deployment_version job_variables = jsonencode({ cpu = 2048 memory = 4096 image = “084375562450.dkr.ecr.us-east-1.amazonaws.com/analytics-api:1191584_pipelines” # replace with var.pipeline_image env = { API_KEY = var.api_key DASK_COILED__TOKEN = var.coiled_token AWS_ACCESS_KEY_ID = var.aws_access_key_id AWS_SECRET_ACCESS_KEY = var.aws_secret_access_key } command = [“python”, “-m”, “dist_flow”] }) }
m
thought for 509.1 seconds
Thanks for sharing the HCL. The short answer: that Terraform resource looks like it targets an older provider/model. In Prefect 3.x,
prefect_deployment_v2
is deprecated. You’ll want to use the current
prefect_deployment
resource and ensure you include an
entrypoint
(required in 3.x) along with your work pool and job variables. A couple of quick checks and fixes: - Confirm your Prefect version (2.x vs 3.x), Prefect Cloud vs OSS, and the Terraform provider version (
PrefectHQ/prefect
). Also, please share the exact “deprecated” message you’re seeing so I can be precise. - In 3.x, deployments must include an
entrypoint
in the form
path/to/file.py:flow_function_name
. - Keep using
work_pool_name
and
job_variables
for ECS (image, cpu, memory, env, command) — those map correctly to ECS work pools in 3.x. - Avoid Slack link formatting in your HCL; the image string should be a plain image reference. Example: Prefect 3.x with ECS work pool and a deployment via Terraform
Copy code
# Example variables you referenced
variable "api_key" {}
variable "coiled_token" {}
variable "aws_access_key_id" {}
variable "aws_secret_access_key" {}

# ECS work pool
resource "prefect_work_pool" "ecs_pool" {
  name = "ecs-pool"
  type = "ecs"

  # Optional: set or tweak the base job template for the pool
  base_job_template = jsonencode({
    image  = "<http://084375562450.dkr.ecr.us-east-1.amazonaws.com/analytics-api:1191584_pipelines|084375562450.dkr.ecr.us-east-1.amazonaws.com/analytics-api:1191584_pipelines>"
    cpu    = 2048
    memory = 4096
    env    = {}
    command = ["python", "-m", "dist_flow"]
  })
}

# Your flow record (make sure this exists in your provider version; otherwise use the flow name directly in the deployment)
resource "prefect_flow" "dist_alerts_update" {
  name = "dist_alerts_update"
}

# Current deployment resource (replace prefect_deployment_v2)
resource "prefect_deployment" "dist_alerts" {
  name            = "DIST-data-update"
  flow_id         = prefect_flow.dist_alerts_update.id
  work_pool_name  = prefect_work_pool.ecs_pool.name

  # Required in 3.x so Prefect knows how to load your flow
  path            = "./"
  entrypoint      = "dist_flow.py:dist_alerts_update"  # adjust to your file:flow_function

  # Optional: parameters your flow expects
  parameters      = jsonencode({})

  # Job variables override the pool's base job template for this deployment
  job_variables   = jsonencode({
    image  = "<http://084375562450.dkr.ecr.us-east-1.amazonaws.com/analytics-api:1191584_pipelines|084375562450.dkr.ecr.us-east-1.amazonaws.com/analytics-api:1191584_pipelines>"
    cpu    = 2048
    memory = 4096
    env    = {
      API_KEY              = var.api_key
      DASK_COILED__TOKEN   = var.coiled_token
      AWS_ACCESS_KEY_ID    = var.aws_access_key_id
      AWS_SECRET_ACCESS_KEY= var.aws_secret_access_key
    }
    command = ["python", "-m", "dist_flow"]
  })
}
Notes and common pitfalls - If you omit
entrypoint
in Prefect 3.x, the deployment won’t be runnable because the server cannot locate your flow code. Adding it usually resolves the “not runnable” symptom. - Ensure your work pool is a 3.x worker-based pool (e.g., type
ecs
), not an old agent/queue configuration. - Don’t include Slack-formatted links in Terraform strings; use plain image strings (e.g., `084375562450.dkr.ecr.us-east-1.amazonaws.com/analytics-api:1191584_pipelines`). - Be cautious storing secrets in Terraform state; consider moving secrets to a secret manager or Prefect variables/blocks instead of inline env. Alternatives (if you want to skip Terraform for deployments) - In Prefect 3.x, the recommended path is using
prefect.yaml
+
prefect deploy
, or Pythonic deploys via
Flow.from_source(...).deploy(...)
. Details: - Prefect YAML pull and deploy concepts: https://docs.prefect.io/v3/deploy/infrastructure-concepts/prefect-yaml#the-pull-action - Work pools: https://docs-3.prefect.io/v3/how-to-guides/deployment_infra/manage-work-pools If you can share: - Your Prefect version and Terraform provider version - The exact deprecation message - The type/name of the work pool you’re pointing at
…I can tailor the exact HCL you need (and confirm the right resource names for your provider version).