Set up event notification for game session placement - Amazon GameLift

Set up event notification for game session placement

If you're using queues to manage game session placement in your game, you can use event notifications to monitor the status of individual placement requests. We recommend setting up event notifications for all games with high-volume placement activity.

There are two options for setting up event notifications.

  • Have GameLift publish event notifications to an Amazon Simple Notification Service (SNS) topic using a queue.

  • Use automatically published Amazon EventBridge events and its suite of tools for managing events.

For a list of game session placement events emitted by GameLift, see Game session placement events.

Set up an SNS topic

For GameLift to publish all events generated by a game session queue to an SNS topic, set the notification target field to an SNS topic.

To set up an SNS topic for GameLift event notification

  1. Sign in to the AWS Management Console and open the Amazon SNS console at https://console.aws.amazon.com/sns/v3/home.

  2. From the SNS Topics page, choose Create topic and follow the instructions to create your topic.

  3. Under Access policy do the following:

    1. Choose the Advanced method.

    2. Add the bolded section of the JSON object below to the existing policy.

      { "Version": "2008-10-17", "Id": "__default_policy_ID", "Statement": [ { "Sid": "__default_statement_ID", "Effect": "Allow", "Principal": { "AWS": "*" }, "Action": [ "SNS:GetTopicAttributes", "SNS:SetTopicAttributes", "SNS:AddPermission", "SNS:RemovePermission", "SNS:DeleteTopic", "SNS:Subscribe", "SNS:ListSubscriptionsByTopic", "SNS:Publish" ], "Resource": "arn:aws:sns:your_region:your_account:your_topic_name", "Condition": { "StringEquals": { "AWS:SourceAccount": "your_account" } } }, { "Sid": "__console_pub_0", "Effect": "Allow", "Principal": { "Service": "gamelift.amazonaws.com" }, "Action": "sns:Publish", "Resource": "arn:aws:sns:your_region:your_account:your_topic_name", "Condition": { "ArnLike": { "aws:SourceArn": "arn:aws:gamelift:your_region:your_account:gamesessionqueue/your_queue_name" } } } ] }
    3. (Optional) Add additional access control to the topic by adding conditions to the resource policy.

  4. Choose Create topic.

  5. After you've created your SNS topic, add it to queues during queue creation or edit an existing queue to add it.

Set up EventBridge

GameLift automatically posts all game session placement events to EventBridge. With EventBridge you can set up rules to have events routed to a range of targets, including SNS topics and other AWS services for processing. For example, you might set a rule to route the event PlacementFulfilled to an AWS Lambda function that handles tasks that precede connecting to a game session. For more information about EventBridge, see What is Amazon EventBridge? in the Amazon EventBridge User Guide.

To get started with GameLift events in EventBridge, see Getting started with Amazon EventBridge. Be sure that you're in the AWS Region where you created your game session queue.

The following are some examples of EventBridge rules to use with GameLift queues:

  • Matches events from all GameLift queues

    { "source": [ "aws.gamelift" ], "detail-type": [ "GameLift Queue Placement Event" ] }
  • Matches events from a specific queue

    { "source": [ "aws.gamelift" ], "detail-type": [ "GameLift Queue Placement Event" ], "resources": [ "arn:aws:gamelift:your_region:your_account:gamesessionqueue/your_queue_name" ] }