I get the following error - ```│ Error: Normalized...
# ask-community
v
I get the following error -
Copy code
│ Error: Normalized JSON Unmarshal Error │  │  with module.flows.prefect_deployment.deployment, │  on ../../modules/flows/main.tf line 7, in resource "prefect_deployment" "deployment": │  7: resource "prefect_deployment" "deployment" { │  │ json string value is null
c
You may be missing additional deployment args. We solved it by adding
parameters
and
parameter_openapi_schema
. It's a bit confusing because the error doesn't specify what is null. You can set
parameters
to an empty json object if you pass in run params elsewhere.
v
Copy code
"prefect_flow" "flow" {
  name         = "cowsay-flow"
  workspace_id = var.prefect_cloud_workspace_id
  tags         = ["tf-test"]
}
#
resource "prefect_deployment" "deployment" {
  name                     = "Cowsay Example Deployment"
  description              = "string"
  workspace_id             = var.prefect_cloud_workspace_id
  flow_id                  = prefect_flow.flow.id
  entrypoint               = "cowsay_example.py:cowsay_flow"
  tags                     = ["staging"]
  enforce_parameter_schema = false
  parameters = jsonencode({
    "creature" : "cow",
    "message"  :"Hello World!"
  })
  parameter_openapi_schema = jsonencode({
    "type" : "object",
    "properties" : {
      "creature" :  {"type": "string"}
      "message" : {"type": "string"}
    }
  })
  paused              = false
  storage_document_id = "eb5bbb9b-b499-4895-8932-8e366aa4b627"
  version             = "v1.1.1"
  work_pool_name      = "main"
  work_queue_name     = "default"
}
I see this error even after passing parameters and parameter_openapi_schema
Copy code
│ Error: Normalized JSON Unmarshal Error │  │  with module.flows.prefect_deployment.deployment, │  on ../../modules/flows/main.tf line 7, in resource "prefect_deployment" "deployment": │  7: resource "prefect_deployment" "deployment" { │  │ json string value is null
@Mitch Nielsen @Caleb
m
hmm, nothing jumps out to me immediately, but I can't see your entire config. you can try running with
TF_LOG=debug
and see if that reports anything helpful (that error message doesn't appear to be coming from our provider from what I can see in the source code). if the debug logs don't answer the question, please open an issue in our tracker and we can try to reproduce 👍
v
@Mitch Nielsen - This is what I see after running with TF_LOG=debug -
Copy code
│ Error: Normalized JSON Unmarshal Error │  │  with module.flows.prefect_deployment.deployment, │  on ../../modules/flows/main.tf line 7, in resource "prefect_deployment" "deployment": │  7: resource "prefect_deployment" "deployment" { │  │ json string value is null ╵ 2024-10-28T21:47:39.083Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF" 2024-10-28T21:47:39.085Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.opentofu.org/prefecthq/prefect/2.3.0/linux_amd64/terraform-provider-prefect_v2.3.0 pid=92 2024-10-28T21:47:39.086Z [DEBUG] provider: plugin exited [01JBAFEXR70ME9JN0GVB6ES058] Unexpected exit code when applying changes: 1 [01JBAFEXR70ME9JN0GVB6ES058] Uploading the list of managed resources...
m
hmm, not seeing anything helpful from that. could you please open an issue with the relevant info and we'll try to replicate it?
v
ok will do - this is just an example deployment via terraform . I am trying to get atleast a sample one working via terraform
@Mitch Nielsen - Here is the issue that I have filed - https://github.com/PrefectHQ/terraform-provider-prefect/issues/289 Thanks
thank you 1
@Mitch Nielsen - thanks for looking into this issue- i was able to get the flow to be deployed after passing all the optional params as you mentioned in the PR. But as you can see in my terraform code - i refer to the github repo block via storage_document_id which i dont see in the UI in the pull section . Hence i am not able to run the flow
Screenshot 2024-10-28 at 4.31.28 PM.png
m
I’m on mobile right now but check out our Terraform docs page, under the Blocks resource. You’ll see an example where you refer to another block using the “$ref” syntax
Copy code
resource "prefect_block" "my_dbt_run_operation_block" {
  name      = "my-dbt-operations"
  type_slug = "dbt-core-operation"

  # note the "$ref" key wrapping the "block_document_id" reference
  data = jsonencode({
    "commands"        = ["dbt deps", "dbt seed", "dbt run"]
    "dbt_cli_profile" = { "$ref" : { "block_document_id" : prefect_block.my_dbt_cli_profile.id } }
  })
}