This CloudFormation template demonstrates the general mechanism for connecting an AWS Lambda
function to AWS Deadline Cloud job events through Amazon EventBridge. The specific scenario it
implements is sending a Slack notification whenever a job completes
(SUCCEEDED) or fails (FAILED).
Deadline Cloud publishes events to EventBridge on the default event bus of the AWS account and Region that owns the farm. This template creates an EventBridge rule that matches those job events and invokes a Lambda function, which posts a formatted message to a Slack channel using an Incoming Webhook.
You can adapt the Lambda function to do anything else you like with the event: send an email, open a ticket, update a dashboard, or trigger a downstream workflow.
This sample uses Slack, but many messaging apps expose the same style of incoming webhook: you
create a webhook URL and POST a JSON message to it. To target one of these instead, set that
app's webhook URL as the SLACK_WEBHOOK_URL environment variable and adjust the JSON body the
Lambda function builds to match the app's expected payload (each app formats its message JSON
differently). The docs below explain how to create a webhook for each:
flowchart LR
A["Deadline Cloud job finishes"] -->|"'Job Run Status Change' event<br/>(source: aws.deadline)"| B["EventBridge rule<br/>(matches SUCCEEDED or FAILED)"]
B --> C["Lambda function<br/>(formats a message)"]
C -->|HTTPS POST| D["Slack webhook"]
The Job Run Status Change event carries a detail payload with the job's identifiers and its
new status:
{
"version": "0",
"detail-type": "Job Run Status Change",
"source": "aws.deadline",
"account": "111122223333",
"region": "us-west-2",
"resources": [],
"detail": {
"farmId": "farm-0123456789abcdef0123456789abcdef",
"queueId": "queue-0123456789abcdef0123456789abcdef",
"jobId": "job-0123456789abcdef0123456789abcdef",
"previousTaskRunStatus": "RUNNING",
"taskRunStatus": "SUCCEEDED",
"taskRunStatusCounts": {
"SUCCEEDED": 1,
"FAILED": 0,
"...": 0
}
}
}The EventBridge rule filters on detail.taskRunStatus so the Lambda function is only invoked for
finished jobs, not for every intermediate status change.
- IAM role (
JobEventsSlackFunctionRole): Execution role for the Lambda function. It grants only CloudWatch Logs write access (via theAWSLambdaBasicExecutionRolemanaged policy). The function needs no other AWS permissions because it reaches Slack over HTTPS. - Lambda function (
JobEventsSlackFunction): A small Python function (standard library only, defined inline in the template) that formats the job event and posts it to the Slack webhook URL held in itsSLACK_WEBHOOK_URLenvironment variable. - Lambda permission (
JobEventsSlackFunctionPermission): Allows EventBridge to invoke the function. - EventBridge rule (
JobEventsRule): MatchesJob Run Status Changeevents with ataskRunStatusofSUCCEEDEDorFAILED(optionally scoped to a single farm) and targets the Lambda function.
- A Deadline Cloud farm in the same AWS account and Region where you deploy this stack. Job events are delivered to the event bus of the farm's account and Region, so the stack must be deployed there.
- A Slack Incoming Webhook URL. To create one:
- Go to https://api.slack.com/apps and create (or open) a Slack app in your workspace.
- Enable Incoming Webhooks, then Add New Webhook to Workspace and choose the channel to post to.
- Copy the generated webhook URL. It has the form
https://hooks.slack.com/services/<workspace-id>/<channel-id>/<token>.
- The AWS CLI installed and configured with credentials for the account (if deploying via CLI).
| Parameter | Default | Description |
|---|---|---|
EventSource |
aws.deadline |
EventBridge source for Deadline Cloud events. Keep the default for production. |
FarmId |
(empty) | Optional. Restrict notifications to a single farm ID. Leave blank for all farms. |
SlackWebhookUrl |
(empty) | Optional. Slack webhook URL. Can be left blank and set on the Lambda function later. |
aws cloudformation deploy \
--stack-name deadline-job-events-slack \
--template-file job_events_slack_lambda_template.yaml \
--capabilities CAPABILITY_IAM \
--region us-west-2 \
--parameter-overrides \
SlackWebhookUrl='https://hooks.slack.com/services/<workspace-id>/<channel-id>/<token>'Replace the webhook URL with your own. To scope notifications to a single farm, add
FarmId=farm-... to --parameter-overrides.
If you prefer not to pass the webhook URL as a stack parameter, deploy without it and then set the environment variable directly on the Lambda function:
aws lambda update-function-configuration \
--function-name <FunctionName-from-stack-outputs> \
--environment "Variables={SLACK_WEBHOOK_URL=https://hooks.slack.com/services/<workspace-id>/<channel-id>/<token>}" \
--region us-west-2Get <FunctionName-from-stack-outputs> from the stack's FunctionName output.
- Open the AWS CloudFormation console in the Region that owns your farm.
- Choose Create stack → With new resources (standard).
- Upload
job_events_slack_lambda_template.yaml. - Provide the parameters (at minimum, your
SlackWebhookUrl). - Acknowledge that the stack creates IAM resources, and create the stack.
The Lambda function posts a message using Slack's text
field, formatted with mrkdwn. The message is
built from the following values taken from the event:
| Line | Source field | Example |
|---|---|---|
Deadline Cloud job <status> |
detail.taskRunStatus (lower-cased) |
Deadline Cloud job succeeded |
Job |
detail.jobId |
job-0123456789abcdef0123456789abcdef |
Queue |
detail.queueId |
queue-0123456789abcdef0123456789abcdef |
Farm |
detail.farmId |
farm-0123456789abcdef0123456789abcdef |
Region |
top-level region |
us-west-2 |
A delivered message looks like this:
Deadline Cloud job succeeded
Job: job-0123456789abcdef0123456789abcdef
Queue: queue-0123456789abcdef0123456789abcdef
Farm: farm-0123456789abcdef0123456789abcdef
Region: us-west-2
The exact JSON posted to the webhook is:
{
"text": "*Deadline Cloud job succeeded*\nJob: `job-0123456789abcdef0123456789abcdef`\nQueue: `queue-0123456789abcdef0123456789abcdef`\nFarm: `farm-0123456789abcdef0123456789abcdef`\nRegion: `us-west-2`"
}To change what the message says, edit the text value the Lambda function builds in the template.
Any field from the event detail (see the JSON example above) is available to include.
Submit a job to your farm and let it finish (or cancel a task so it fails). Within a few seconds of
the job reaching SUCCEEDED or FAILED, a message appears in your Slack channel. You can also
inspect the function's execution in its CloudWatch Logs log group (/aws/lambda/<FunctionName>).
- Managing Deadline Cloud events using Amazon EventBridge: how Deadline Cloud publishes events, the list of event detail types, and how to write rules to route them.
- Deadline Cloud events detail reference:
the
detailschema for each event, includingJob Run Status Change. - Amazon EventBridge event patterns:
how the rule's
EventPatternmatching works. - Amazon EventBridge rule targets: how a rule invokes a target such as a Lambda function.
- Using AWS Lambda with Amazon EventBridge: the Lambda side of the integration.
- Sending messages using incoming webhooks and message payload formatting: the Slack APIs used by the Lambda function.