Amazon Game Tech Blog

Game developers guide to getting started with the AWS SDK

Gaming companies use Amazon Web Services for many reasons. It’s ability to scale enables games to support millions of concurrent players, and ensure they enjoy low latency experiences, wherever they are.

But, with hundreds of AWS services, and even more potential use cases, it can be difficult for a game developer to know how to get started.

Today, we’re going to walk you through the very first steps of using AWS for any game development workflow. We’ll offer some best practices on how to use AWS services securely, and show you how to integrate the SDK with your game client in the languages used in major 3D game engines like Unreal, Unity, and Amazon Lumberyard, namely C++ and C#.

Choose your own adventure

The steps to integrate the AWS SDK differ depending on whether you’re working with C++ or C#. Click to follow instructions for your game’s language:

Best practice: Create a layer of indirection between your game and AWS

If your game doesn’t use a server, we recommend minimizing the number of different AWS resources accessed directly from your client. There are two reasons for this; first, it’s a security issue when you expose a lot of API calls from your client. It gives the client (and therefore the user) direct access to AWS service calls, which means malicious entities could gain unintended access to your features, or flood your account with bad API calls. Second, it makes your implementation brittle, forcing you to create client updates every time you want to make a change.

You should think of your AWS implementation as a “black box” service where only the inputs and outputs are seen, and the inner workings are hidden from the client. This way you can change how the back-end works (say using a different database or some new AWS feature) without forcing players to update their devices. It also means you can expose features to your game client through a very small surface and minimize exposure to the API. Really, you only need to expose Amazon Cognito, and AWS Lambda.

Amazon Cognito is used to authenticate users and give them access to your AWS resources without needing to embed a private key in your client. Even when you need to give credentials to users anonymously (meaning any game client can access resources without logging in), it’s far less brittle to allow Amazon Cognito to request keys for the client than it is to ship and rotate keys that are stored on the user’s machine.

AWS Lambda functions are used here as an entry point to all of your AWS resources, which provides a layer of abstraction between your game and AWS features. An AWS Lambda is a function that runs on AWS servers, and doesn’t require any server set up on your part, you just write code. Effectively, your client never needs to directly call an AWS API aside from Lambda as you can call any other AWS service from here.

Some of you may be thinking, what about Amazon API Gateway? Well, that’s definitely an option and there are certainly some operational benefits and it provides yet another layer of security and protection. Another option worth exploring would be to create an Application Load Balancer to create more indirection from your client.

If you have a server for your game,  this security layer is simple. Make as many of your AWS API calls from your server as possible. In fact, with the exception being Amazon Cognito API calls, make all AWS API calls from your game server! This is by far the safest way for you to access AWS resources on behalf of your players and as your server can forward any information from AWS over it’s existing client connection, it makes a lot of sense. We still recommend keeping as small a surface as possible between your game server and AWS services for reasons similar to the above. Updating your AWS backend services will be less likely to result in needing to redeploy your server application, and as bugs do happen, it minimizes your exposure to malicious users who could wreak costly havoc.

 

As always, we want to hear from you. Help drive the learning resources we create by sending your feedback and questions to the Amazon GameDev forums.