Hi community,
I was trying to initiate a Gamelift fleet using an zip file from s3 (created by CDK Asset). However the fleet created will get stuck in "Activating" for more than one hour and then error. No usable event log is emitted from console during "Activating". I can ssh into the game server in error status but not sure if that is helpful.
Any help would be appreciated on how to debug further.
(More context: the server files themselves are fine. I uploaded the zip file directly to create the script and the fleet from the script is created just fine). The s3 access rights seem to be okay too, I followed the example here . The CDK code for uploading server to s3 and creating the script is as follows)
import { Role, PolicyStatement, ServicePrincipal } from "aws-cdk-lib/aws-iam";
import { Asset } from "aws-cdk-lib/aws-s3-assets";
import { Bucket } from "aws-cdk-lib/aws-s3";
import { CfnScript } from "aws-cdk-lib/aws-gamelift";
...
// Upload gamelift real-time server script as cdk asset
const scriptAsset = new Asset(this, "MyAsset", {
path: pathToScript,
});
const assetBucket = Bucket.fromBucketName(
this,
"ScriptAssetBucket",
scriptAsset.s3BucketName
);
const scriptAccessRole = new Role(this, "ScriptAccessRole", {
assumedBy: new ServicePrincipal("gamelift.amazonaws.com"),
});
scriptAccessRole.addToPrincipalPolicy(
new PolicyStatement({
actions: ["s3:GetObject", "s3:GetObjectVersion"],
resources: [`${assetBucket.bucketArn}/${scriptAsset.s3ObjectKey}`],
})
);
const script = new CfnScript(this, "RealTimeScript", {
name: `my-script`,
version: "0.1",
storageLocation: {
bucket: scriptAsset.s3BucketName,
key: scriptAsset.s3ObjectKey,
roleArn: scriptAccessRole.roleArn,
},
});
script.node.addDependency(scriptAccessRole);
Op here. I solved it. The actual reason seems to be: CDK Asset cannot be used to host a game lift script. I ended up using a custom s3 bucket and that solved it.
In my case I always uploaded the script as a zip file and no problem.
Maybe this post can help you: https://github.com/aws/aws-cdk/pull/21805 to disable automatic unzipping when uploading to s3.