- AWS Game Backend Framework Sample Backend Components
- Preliminary setup
- Serverless REST API sample component template
- Loadbalanced AWS Fargate sample component template
These sample components can be deployed to test integration from a game client to a backend using the authentication feature of the custom identity component.
Logs and Distributed Tracing
All the backend template components leverage AWS X-Ray for distributed tracing, as well as AWS CloudWatch for logs. You can find both the logs and the tracing map and individual trace information the AWS CloudWatch console.
Set the const issuerEndpointUrl
in BackendComponentSamples/bin/backend_component_samples.ts
to the value of IssuerEndpointUrl
found in the stack outputs of the CustomIdentityComponentStack. You can find it in the CloudFormation console, or in the terminal after deploying the identity component.
It is recommended to deploy the serverless API Gateway HTTP API backed component template next to test out your integration from a game engine. The templates work as starting points for your own backend development. We'll deploy the PythonServerlessHttpApiStack
that can be found in BackendComponentSamples
.
To deploy the component, follow the Preliminary Setup, and then run the following commands (Note: on Windows make sure to run in Powershell as Administrator):
cd ..
to return to the root andcd BackendComponentSamples
to navigate to samplesnpm install
to install CDK app dependenciescdk synth
to synthesize the CDK app and validate your configuration workscdk deploy PythonServerlessHttpApiStack
to deploy the CDK app to your account
You'll see a new stack deployed in the AWS CloudFormation console, with an API Gateway HTTP API to set and get player data, backed up with Python Lambda functions and an Amazon DynamoDB PlayerData table.
The solution uses Python on AWS Lambda for managing requests to get and set player data. Requests are autenticated on the API Gateway level by validating the JWT token in the Authorization header against the public keys provided by our custom identity component. This is using the native integration of the API Gateway HTTP API.
The python functions use Powertools for Lambda (Python) to provide detailed tracing in AWS X-Ray.
Another option is to deploy the AWS Fargate sample component that deploys an AWS Fargate service with an Application Load Balancer, and use Node.js on the server side. It leverages the aws-verify-jwt package to verify the JWT tokens received from the backend, and sets and gets player data in a DynamoDB table in the same way as the Serverless sample component. You can optionally use this Fargate component as your test integration point within the game engines
To deploy the component, follow the Preliminary Setup, and then run the following commands (Note: on Windows make sure to run in Powershell as Administrator):
- Make sure you have Docker running before you open the terminal, as the deployment process creates a Docker image
cd ..
to return to the root andcd BackendComponentSamples
to navigate to samplesnpm install
to install CDK app dependenciescdk synth
to synthesize the CDK app and validate your configuration workscdk deploy NodeJsFargateApiStack
to deploy the CDK app to your account
The solution has an Application Load Balancer, that integrates with an auto-scaling Node.js application running on AWS Fargate. The application is integrated with AWS X-Ray for distributed tracing by adding a sidecar container for the X-Ray daemon and using the X-Ray SDK to trace requests and integrations with other AWS services. The app is an express web server that will handle set and get requests for player data with authenticated users. It also responds to the health check sent by the Application Load Balancer.