After creating the AWS account, the next step was integrating the GameLift plugin into Unreal Engine, primarily within a custom GameMode class.
Fortunately, AWS provides a well-documented example of a GameMode implementation that includes the GameLift plugin here. This example is heavily commented, making it easy to understand each component of the integration. Notably, it explains the Lambda functions assigned to various delegates, such as OnHealthCheck, which is invoked every 60 seconds to verify that the game server is operating as expected.
Fortunately, AWS provides a well-documented example of a GameMode implementation that includes the GameLift plugin here. This example is heavily commented, making it easy to understand each component of the integration. Notably, it explains the Lambda functions assigned to various delegates, such as OnHealthCheck, which is invoked every 60 seconds to verify that the game server is operating as expected.
//Implement callback function OnHealthCheck
//GameLift invokes this callback approximately every 60 seconds.
//A game server might want to check the health of dependencies, etc.
//Then it returns health status true if healthy, false otherwise.
//The game server must respond within 60 seconds, or GameLift records 'false'.
//In this example, the game server always reports healthy.
auto onHealthCheck = []()
{
UE_LOG(LogTruffleUpServerGameMode, Log, TEXT("Performing Health Check"));
return true;
};
processParameters.OnHealthCheck.BindLambda(onHealthCheck);
The main difference between my implementation and the AWS documentation lies in the way the port number is assigned. While the documentation hardcodes port 777 (Unreal Engine's default port), I opted for a more dynamic approach, allowing users to specify the port via the command prompt.
void ATrouffleUpServerGameMode::parseCommandLinePort(int32& outPort)
{
// add the possibility to define more ports to allow multiple play sessions at the same time
TArray<FString> commandLineTokens, commandLineSwitches;
FCommandLine::Parse(FCommandLine::Get(),commandLineTokens,commandLineSwitches);
for (const auto& token : commandLineSwitches)
{
FString key,value;
if ( token.Split("=",&key,&value))
{
if (key.Equals(TEXT("port"), ESearchCase::IgnoreCase))
{
outPort = FCString::Atoi(*value);
return;
}
}
}
}
Once the implementation was complete, the project was successfully built for both Server and Editor, both within the IDE and directly in the Unreal Engine.

Reminder: As Gamelift uses Openssl under the hood, it is necessary to copy and paste the two previosly generated files in the Server build of the project, this needs to be in the folder that contains the executable file of the project
