Callbacks and Notifications
The Stable Diffusion on Amazon EKS solution adopts an asynchronous inference mode. After an image is generated or an error occurs, users will be notified via Amazon SNS. User applications can subscribe to the SNS topic to receive notifications when image generation is completed.
Adding Subscriptions
Please refer to the Amazon SNS documentation to learn about the types of message destinations supported by SNS.
You can find the ARN of the generated SNS topic from the CloudFormation outputs:
- Go to the AWS CloudFormation Console
- Select Stacks
- In the list, select SdOnEKSStack (or your custom name)
- Select Output
- Record the value of the sdNotificationOutputArn item (in the format
arn:aws:sns:us-east-1:123456789012:SdOnEKSStack-sdNotificationOutputCfn-abcdefgh
)
To receive messages, you need to add your message receiver (such as an Amazon SQS queue, HTTP endpoint, etc.) as a subscription to the SNS topic.
- In the left navigation pane, select Subscriptions.
- On the Subscriptions page, select Create subscription.
- In the Details section of the Create subscription page, do the following:
- For Topic ARN, select the ARN you recorded in the previous step.
- For Protocol, select the type of your receiver.
- For Endpoint, enter the address of your receiver, such as an email address or the ARN of an Amazon SQS queue.
- Select Create subscription
Please refer to Use Amazon SNS with the AWS CLI to add a subscription to the topic.
Callback Message Format
The solution will send task completion notifications to SNS in the following format, regardless of the API version used in the request:
{
"id": "task_id", // Task ID
"result": true, // true for successful completion, false for unsuccessful completion
"image_url": [ // S3 URLs of the generated images, in the format task_id+4_random_digits+image_number, all image links will be included if there are multiple images
"s3://outputbucket/output/test-t2i/test-t2i-abcd-1.png"
],
"output_url": "s3://outputbucket/output/test-t2i/test-t2i-abcd.out", // S3 URL of the task output, containing the full output during runtime
"context": { // Context content attached in the request
"abc": 123
}
}