Set up event notification for game session placement
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 Amazon GameLift publish event notifications to an Amazon Simple Notification Service (Amazon 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 Amazon GameLift, see Game session placement events.
Set up an SNS topic
For Amazon GameLift to publish all events generated by a game session queue to a topic, set the notification target field to a topic.
To set up an SNS topic for Amazon GameLift event notification
Sign in to the AWS Management Console and open the Amazon SNS console at https://console.aws.amazon.com/sns/v3/home
. -
From the SNS Topics page, choose Create topic and follow the instructions to create your topic.
-
Under Access policy, do the following:
-
Choose the Advanced method.
-
Add the following bolded section of the JSON object 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
" } } } ] } -
(Optional) Add additional access control to the topic by adding conditions to the resource policy.
-
-
Choose Create topic.
-
After you've created your SNS topic, add it to queues during queue creation, or edit an existing queue to add it.
Set up an SNS topic with server-side encryption
With server-side encryption (SSE), you can store sensitive data in encrypted topics. SSE protects the contents of messages in Amazon SNS topics using keys that are managed in AWS Key Management Service (AWS KMS). For more information about server-side encryption with Amazon SNS, see Encryption at rest in the Amazon Simple Notification Service Developer Guide.
To set up an SNS topic with server-side encryption, review the following topics:
-
Creating key in the AWS Key Management Service Developer Guide
-
Enabling SSE for a topic in the Amazon Simple Notification Service Developer Guide
When creating your KMS key, use the following KMS key policy:
{ "Effect": "Allow", "Principal": { "Service": "gamelift.amazonaws.com" }, "Action": [ "kms:Decrypt", "kms:GenerateDataKey" ], "Resource": "*", "Condition": { "ArnLike": { "aws:SourceArn": "arn:aws:gamelift:
your_region
:your_account
:gamesessionqueue/your_queue_name
" }, "StringEquals": { "kms:EncryptionContext:aws:sns:topicArn": "arn:aws:sns:your_region
:your_account
:your_sns_topic_name
" } } }
Set up EventBridge
Amazon GameLift automatically posts all game session placement events to EventBridge. With EventBridge you can
set up rules to have events routed to targets for processing. For example, you can 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.
The following are some examples of EventBridge rules to use with Amazon GameLift queues:
Matches events from all Amazon 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
" ] }