Hi All, I've seen a couple of questions around tri...
# ask-community
m
Hi All, I've seen a couple of questions around triggering flows from SNS or from S3 events via SNS notifications, and have managed to set up a webhook and automation that'll trigger an example flow - however I can't make the webhook and automation actually pass anything useful down to the flow - only static "hello" type messages that I type in the automation json. At the moment the below is my best guess - my webhook is trying to turn it to json with
{{ body | tojson }}
and then the automation is trying to receive it with
Copy code
{
  "event": {
    "__prefect_kind": "jinja",
    "template": "{{ triggering_event.payload.body.Message }}"
  }
}
But this approach (and every other) fails with some variation on:
Copy code
Events
Automation action failed
Details
Raw
{
  "id": "3cd564fd-57a5-4d9e-bf08-6d6b848678fd",
  "account": "10cd2793-5f23-4975-8d46-84afe327fe95",
  "event": "prefect-cloud.automation.action.failed",
  "occurred": "2025-03-20T22:43:13.260Z",
  "payload": {
    "action_index": 0,
    "action_type": "run-deployment",
    "invocation": "7f8e662d-e2fb-4122-bc0b-df2a82afec13",
    "reason": "Validation error occurred for 'run-deployment' - Error creating flow run: Validation failed for field 'event'. Failure reason: '' is not of type 'object'",
    "validation_error": "Error creating flow run: Validation failed for field 'event'. Failure reason: '' is not of type 'object'",
    "status_code": 409
  },
Is there a guide somewhere?
I'm adding the automation jinja thing here:
a
what’s the raw event look like from SNS?
m
This is the raw Webhook Received content, with some bits replaced with xxxx for privacy:
Copy code
{
  "id": "xxxx",
  "account": "xxxx",
  "event": "prefect-cloud.webhook.received",
  "occurred": "2025-03-20T22:43:12.716Z",
  "payload": {
    "method": "POST",
    "headers": {
      "host": "api.prefect.cloud",
      "x-amz-sns-message-type": "Notification",
      "x-amz-sns-message-id": "xxxx",
      "x-amz-sns-topic-arn": "xxxx",
      "x-amz-sns-subscription-arn": "xxxx",
      "content-type": "text/plain; charset=UTF-8",
      "content-length": "2073",
      "user-agent": "Amazon Simple Notification Service Agent",
      "accept-encoding": "gzip,deflate",
      "x-request-id": "xxxx"
    },
    "body": "{\n  \"Type\" : \"Notification\",\n  \"MessageId\" : \"3b34d9aa-7b3f-5b7c-be71-b9fce77f3657\",\n  \"TopicArn\" : \"xxxx\",\n  \"Subject\" : \"Wasabi S3 Notification\",\n  \"Message\" : \"{\\\"Records\\\":[{\\\"eventVersion\\\":\\\"0.1\\\",\\\"eventSource\\\":\\\"wasabi:s3\\\",\\\"awsRegion\\\":\\\"eu-north-1\\\",\\\"eventTime\\\":\\\"2025-03-20T22:43:12.393Z\\\",\\\"eventName\\\":\\\"s3:ObjectCreated:Put\\\",\\\"userIdentity\\\":{\\\"principalId\\\":\\\"102\\\"},\\\"requestParameters\\\":{\\\"sourceIPAddress\\\":\\\"193.237.215.124\\\"},\\\"responseElements\\\":{\\\"x-amz-id-2\\\":\\\"Kr/5s4hYaDBvidpqXuEaRU5iavAVSmhFYE0kj6WxDS+7c6IfpzIPdoZ7PAWA4vNHyReLw0dkUrfc\\\",\\\"x-amz-request-id\\\":\\\"E26CB84184B7A029:A\\\"},\\\"s3\\\":{\\\"s3SchemaVersion\\\":\\\"1.0\\\",\\\"configurationId\\\":\\\"FileCreated\\\",\\\"bucket\\\":{\\\"name\\\":\\\"xxxx\\\",\\\"ownerIdentity\\\":{\\\"principalId\\\":\\\"250825\\\"},\\\"arn\\\":\\\"xxxx\\\"},\\\"object\\\":{\\\"key\\\":\\\"dockerfile_cpu\\\",\\\"size\\\":2434,\\\"eTag\\\":\\\"56b57a25f786797cf60d7828052c4790\\\",\\\"sequencer\\\":\\\"1\\\"}},\\\"enhancedParameters\\\":{\\\"Content-Type\\\":\\\"application/octet-stream\\\",\\\"principalName\\\":\\\"xxxx\\\",\\\"wasabiCanonicalId\\\":\\\"9IAO1G9PDK3CIEV39EKD1\\\",\\\"x-amz-meta-s3b-last-modified\\\":\\\"20250320T160950Z\\\",\\\"x-amz-meta-sha256\\\":\\\"6326a5e03fcd39948d078902bcf7799cd61c27b9bfd90755b0d18d84315d0873\\\"}}]}\\n\",\n  \"Timestamp\" : \"2025-03-20T22:43:12.552Z\",\n  \"SignatureVersion\" : \"1\",\n  \"Signature\" : \"MVkb8rK2cFZw7VgGvV/s8A4CnfpOdkm/9qtJRd5T+oQ0wFC8GLQR2qIRFGh6+MC+DnEX/teC30ugI4f4v2vt3h2t8T9bp/c9e+biTZT8U1FiwNoHm9/P5evuDAeEBeNx+fiIPvvkZButd+UFmoarjrqNi05A84b/lwHMSim+9K7N4KH5xRHnzrbePgbcTOYPesrbJ6TlnXytfu/nAr4Cp+YdtYEiePvmNy7hAiGLxxOdOf3X3BvwsmPEwOqnEj6rS4SeUqfqDjV9ntOmU/3y2dy3c4ZwEl97lbolGV+J4L4JXz4hGDxDT4txECyFFIL5kI03YMTdqYWdMA8WX+y61w==\",\n  \"SigningCertURL\" : \"xxxx\",\n  \"UnsubscribeURL\" : \"xxxx"\n}",
    "raw_body": "{\n  \"Type\" : \"Notification\",\n  \"MessageId\" : \"3b34d9aa-7b3f-5b7c-be71-b9fce77f3657\",\n  \"TopicArn\" : \xxxx\",\n  \"Subject\" : \"Wasabi S3 Notification\",\n  \"Message\" : \"{\\\"Records\\\":[{\\\"eventVersion\\\":\\\"0.1\\\",\\\"eventSource\\\":\\\"wasabi:s3\\\",\\\"awsRegion\\\":\\\"eu-north-1\\\",\\\"eventTime\\\":\\\"2025-03-20T22:43:12.393Z\\\",\\\"eventName\\\":\\\"s3:ObjectCreated:Put\\\",\\\"userIdentity\\\":{\\\"principalId\\\":\\\"102\\\"},\\\"requestParameters\\\":{\\\"sourceIPAddress\\\":\\\"193.237.215.124\\\"},\\\"responseElements\\\":{\\\"x-amz-id-2\\\":\\\"Kr/5s4hYaDBvidpqXuEaRU5iavAVSmhFYE0kj6WxDS+7c6IfpzIPdoZ7PAWA4vNHyReLw0dkUrfc\\\",\\\"x-amz-request-id\\\":\\\"E26CB84184B7A029:A\\\"},\\\"s3\\\":{\\\"s3SchemaVersion\\\":\\\"1.0\\\",\\\"configurationId\\\":\\\"FileCreated\\\",\\\"bucket\\\":{\\\"name\\\":\\\"xxxx\\\",\\\"ownerIdentity\\\":{\\\"principalId\\\":\\\"250825\\\"},\\\"arn\\\":\\\"xxxx\\\"},\\\"object\\\":{\\\"key\\\":\\\"dockerfile_cpu\\\",\\\"size\\\":2434,\\\"eTag\\\":\\\"56b57a25f786797cf60d7828052c4790\\\",\\\"sequencer\\\":\\\"1\\\"}},\\\"enhancedParameters\\\":{\\\"Content-Type\\\":\\\"application/octet-stream\\\",\\\"principalName\\\":\\\"xxxx\\\",\\\"wasabiCanonicalId\\\":\\\"9IAO1G9PDK3CIEV39EKD1\\\",\\\"x-amz-meta-s3b-last-modified\\\":\\\"20250320T160950Z\\\",\\\"x-amz-meta-sha256\\\":\\\"6326a5e03fcd39948d078902bcf7799cd61c27b9bfd90755b0d18d84315d0873\\\"}}]}\\n\",\n  \"Timestamp\" : \"2025-03-20T22:43:12.552Z\",\n  \"SignatureVersion\" : \"1\",\n  \"Signature\" : \"xxxx",\n  \"SigningCertURL\" : \"xxxx",\n  \"UnsubscribeURL\" : \"xxxx"\n}"
  },
  "received": "2025-03-20T22:43:12.717Z",
  "related": [
    {
      "prefect.resource.id": "prefect-cloud.webhook.xxxx",
      "prefect.resource.name": "SNS-Trigger",
      "prefect.resource.role": "webhook"
    }
  ],
  "resource": {
    "prefect.resource.id": "prefect-cloud.webhook.xxxx",
    "prefect.resource.name": "SNS-Trigger"
  },
  "workspace": "xxxx"
}
It'd be fine if all of this came down to the flow - I can work on it from there.
ok - in the end the issue was down to the naming - it was supposed to be event.payload - and so look like this:
Copy code
{
  "event": {
    "template": "{{ event.payload.body }}",
    "__prefect_kind": "jinja"
  }
}