@aws-cdk/aws-gamelift-alpha 2.49.1-alpha.0 → 2.51.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +3892 -182
- package/.jsii.tabl.json.gz +0 -0
- package/.warnings.jsii.js +155 -1
- package/README.md +417 -7
- package/lib/build-fleet.d.ts +81 -0
- package/lib/build-fleet.js +155 -0
- package/lib/build.js +4 -3
- package/lib/content.d.ts +3 -3
- package/lib/content.js +21 -8
- package/lib/fleet-base.d.ts +408 -0
- package/lib/fleet-base.js +233 -0
- package/lib/game-server-group.d.ts +334 -0
- package/lib/game-server-group.js +271 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +5 -1
- package/lib/ingress-rule.d.ts +117 -0
- package/lib/ingress-rule.js +168 -0
- package/lib/script.js +2 -2
- package/package.json +9 -8
- package/rosetta/default.ts-fixture +2 -1
package/.jsii.tabl.json.gz
CHANGED
|
Binary file
|
package/.warnings.jsii.js
CHANGED
|
@@ -50,6 +50,160 @@ function _aws_cdk_aws_gamelift_alpha_ScriptProps(p) {
|
|
|
50
50
|
}
|
|
51
51
|
function _aws_cdk_aws_gamelift_alpha_Script(p) {
|
|
52
52
|
}
|
|
53
|
+
function _aws_cdk_aws_gamelift_alpha_AutoScalingPolicy(p) {
|
|
54
|
+
}
|
|
55
|
+
function _aws_cdk_aws_gamelift_alpha_InstanceDefinition(p) {
|
|
56
|
+
}
|
|
57
|
+
function _aws_cdk_aws_gamelift_alpha_DeleteOption(p) {
|
|
58
|
+
}
|
|
59
|
+
function _aws_cdk_aws_gamelift_alpha_BalancingStrategy(p) {
|
|
60
|
+
}
|
|
61
|
+
function _aws_cdk_aws_gamelift_alpha_IGameServerGroup(p) {
|
|
62
|
+
}
|
|
63
|
+
function _aws_cdk_aws_gamelift_alpha_GameServerGroupBase(p) {
|
|
64
|
+
}
|
|
65
|
+
function _aws_cdk_aws_gamelift_alpha_GameServerGroupAttributes(p) {
|
|
66
|
+
}
|
|
67
|
+
function _aws_cdk_aws_gamelift_alpha_GameServerGroupProps(p) {
|
|
68
|
+
if (p == null)
|
|
69
|
+
return;
|
|
70
|
+
visitedObjects.add(p);
|
|
71
|
+
try {
|
|
72
|
+
if (p.instanceDefinitions != null)
|
|
73
|
+
for (const o of p.instanceDefinitions)
|
|
74
|
+
if (!visitedObjects.has(o))
|
|
75
|
+
_aws_cdk_aws_gamelift_alpha_InstanceDefinition(o);
|
|
76
|
+
if (!visitedObjects.has(p.autoScalingPolicy))
|
|
77
|
+
_aws_cdk_aws_gamelift_alpha_AutoScalingPolicy(p.autoScalingPolicy);
|
|
78
|
+
if (!visitedObjects.has(p.balancingStrategy))
|
|
79
|
+
_aws_cdk_aws_gamelift_alpha_BalancingStrategy(p.balancingStrategy);
|
|
80
|
+
if (!visitedObjects.has(p.deleteOption))
|
|
81
|
+
_aws_cdk_aws_gamelift_alpha_DeleteOption(p.deleteOption);
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
visitedObjects.delete(p);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function _aws_cdk_aws_gamelift_alpha_GameServerGroup(p) {
|
|
88
|
+
}
|
|
89
|
+
function _aws_cdk_aws_gamelift_alpha_Protocol(p) {
|
|
90
|
+
}
|
|
91
|
+
function _aws_cdk_aws_gamelift_alpha_PortProps(p) {
|
|
92
|
+
if (p == null)
|
|
93
|
+
return;
|
|
94
|
+
visitedObjects.add(p);
|
|
95
|
+
try {
|
|
96
|
+
if (!visitedObjects.has(p.protocol))
|
|
97
|
+
_aws_cdk_aws_gamelift_alpha_Protocol(p.protocol);
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
visitedObjects.delete(p);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function _aws_cdk_aws_gamelift_alpha_Port(p) {
|
|
104
|
+
}
|
|
105
|
+
function _aws_cdk_aws_gamelift_alpha_IPeer(p) {
|
|
106
|
+
}
|
|
107
|
+
function _aws_cdk_aws_gamelift_alpha_Peer(p) {
|
|
108
|
+
}
|
|
109
|
+
function _aws_cdk_aws_gamelift_alpha_IngressRule(p) {
|
|
110
|
+
if (p == null)
|
|
111
|
+
return;
|
|
112
|
+
visitedObjects.add(p);
|
|
113
|
+
try {
|
|
114
|
+
if (!visitedObjects.has(p.port))
|
|
115
|
+
_aws_cdk_aws_gamelift_alpha_Port(p.port);
|
|
116
|
+
if (!visitedObjects.has(p.source))
|
|
117
|
+
_aws_cdk_aws_gamelift_alpha_IPeer(p.source);
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
visitedObjects.delete(p);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function _aws_cdk_aws_gamelift_alpha_LocationCapacity(p) {
|
|
124
|
+
}
|
|
125
|
+
function _aws_cdk_aws_gamelift_alpha_Location(p) {
|
|
126
|
+
if (p == null)
|
|
127
|
+
return;
|
|
128
|
+
visitedObjects.add(p);
|
|
129
|
+
try {
|
|
130
|
+
if (!visitedObjects.has(p.capacity))
|
|
131
|
+
_aws_cdk_aws_gamelift_alpha_LocationCapacity(p.capacity);
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
visitedObjects.delete(p);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function _aws_cdk_aws_gamelift_alpha_ServerProcess(p) {
|
|
138
|
+
}
|
|
139
|
+
function _aws_cdk_aws_gamelift_alpha_RuntimeConfiguration(p) {
|
|
140
|
+
if (p == null)
|
|
141
|
+
return;
|
|
142
|
+
visitedObjects.add(p);
|
|
143
|
+
try {
|
|
144
|
+
if (p.serverProcesses != null)
|
|
145
|
+
for (const o of p.serverProcesses)
|
|
146
|
+
if (!visitedObjects.has(o))
|
|
147
|
+
_aws_cdk_aws_gamelift_alpha_ServerProcess(o);
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
visitedObjects.delete(p);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function _aws_cdk_aws_gamelift_alpha_ResourceCreationLimitPolicy(p) {
|
|
154
|
+
}
|
|
155
|
+
function _aws_cdk_aws_gamelift_alpha_IFleet(p) {
|
|
156
|
+
}
|
|
157
|
+
function _aws_cdk_aws_gamelift_alpha_FleetProps(p) {
|
|
158
|
+
if (p == null)
|
|
159
|
+
return;
|
|
160
|
+
visitedObjects.add(p);
|
|
161
|
+
try {
|
|
162
|
+
if (!visitedObjects.has(p.runtimeConfiguration))
|
|
163
|
+
_aws_cdk_aws_gamelift_alpha_RuntimeConfiguration(p.runtimeConfiguration);
|
|
164
|
+
if (p.locations != null)
|
|
165
|
+
for (const o of p.locations)
|
|
166
|
+
if (!visitedObjects.has(o))
|
|
167
|
+
_aws_cdk_aws_gamelift_alpha_Location(o);
|
|
168
|
+
if (!visitedObjects.has(p.resourceCreationLimitPolicy))
|
|
169
|
+
_aws_cdk_aws_gamelift_alpha_ResourceCreationLimitPolicy(p.resourceCreationLimitPolicy);
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
visitedObjects.delete(p);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function _aws_cdk_aws_gamelift_alpha_FleetAttributes(p) {
|
|
176
|
+
}
|
|
177
|
+
function _aws_cdk_aws_gamelift_alpha_FleetBase(p) {
|
|
178
|
+
}
|
|
179
|
+
function _aws_cdk_aws_gamelift_alpha_IBuildFleet(p) {
|
|
180
|
+
}
|
|
181
|
+
function _aws_cdk_aws_gamelift_alpha_BuildFleetProps(p) {
|
|
182
|
+
if (p == null)
|
|
183
|
+
return;
|
|
184
|
+
visitedObjects.add(p);
|
|
185
|
+
try {
|
|
186
|
+
if (!visitedObjects.has(p.content))
|
|
187
|
+
_aws_cdk_aws_gamelift_alpha_IBuild(p.content);
|
|
188
|
+
if (p.ingressRules != null)
|
|
189
|
+
for (const o of p.ingressRules)
|
|
190
|
+
if (!visitedObjects.has(o))
|
|
191
|
+
_aws_cdk_aws_gamelift_alpha_IngressRule(o);
|
|
192
|
+
if (!visitedObjects.has(p.runtimeConfiguration))
|
|
193
|
+
_aws_cdk_aws_gamelift_alpha_RuntimeConfiguration(p.runtimeConfiguration);
|
|
194
|
+
if (p.locations != null)
|
|
195
|
+
for (const o of p.locations)
|
|
196
|
+
if (!visitedObjects.has(o))
|
|
197
|
+
_aws_cdk_aws_gamelift_alpha_Location(o);
|
|
198
|
+
if (!visitedObjects.has(p.resourceCreationLimitPolicy))
|
|
199
|
+
_aws_cdk_aws_gamelift_alpha_ResourceCreationLimitPolicy(p.resourceCreationLimitPolicy);
|
|
200
|
+
}
|
|
201
|
+
finally {
|
|
202
|
+
visitedObjects.delete(p);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function _aws_cdk_aws_gamelift_alpha_BuildFleet(p) {
|
|
206
|
+
}
|
|
53
207
|
function print(name, deprecationMessage) {
|
|
54
208
|
const deprecated = process.env.JSII_DEPRECATED;
|
|
55
209
|
const deprecationMode = ["warn", "fail", "quiet"].includes(deprecated) ? deprecated : "warn";
|
|
@@ -86,4 +240,4 @@ class DeprecationError extends Error {
|
|
|
86
240
|
});
|
|
87
241
|
}
|
|
88
242
|
}
|
|
89
|
-
module.exports = { print, getPropertyDescriptor, DeprecationError, _aws_cdk_aws_gamelift_alpha_Content, _aws_cdk_aws_gamelift_alpha_ContentConfig, _aws_cdk_aws_gamelift_alpha_S3Content, _aws_cdk_aws_gamelift_alpha_AssetContent, _aws_cdk_aws_gamelift_alpha_IBuild, _aws_cdk_aws_gamelift_alpha_BuildBase, _aws_cdk_aws_gamelift_alpha_OperatingSystem, _aws_cdk_aws_gamelift_alpha_BuildAttributes, _aws_cdk_aws_gamelift_alpha_BuildProps, _aws_cdk_aws_gamelift_alpha_Build, _aws_cdk_aws_gamelift_alpha_IScript, _aws_cdk_aws_gamelift_alpha_ScriptBase, _aws_cdk_aws_gamelift_alpha_ScriptAttributes, _aws_cdk_aws_gamelift_alpha_ScriptProps, _aws_cdk_aws_gamelift_alpha_Script };
|
|
243
|
+
module.exports = { print, getPropertyDescriptor, DeprecationError, _aws_cdk_aws_gamelift_alpha_Content, _aws_cdk_aws_gamelift_alpha_ContentConfig, _aws_cdk_aws_gamelift_alpha_S3Content, _aws_cdk_aws_gamelift_alpha_AssetContent, _aws_cdk_aws_gamelift_alpha_IBuild, _aws_cdk_aws_gamelift_alpha_BuildBase, _aws_cdk_aws_gamelift_alpha_OperatingSystem, _aws_cdk_aws_gamelift_alpha_BuildAttributes, _aws_cdk_aws_gamelift_alpha_BuildProps, _aws_cdk_aws_gamelift_alpha_Build, _aws_cdk_aws_gamelift_alpha_IScript, _aws_cdk_aws_gamelift_alpha_ScriptBase, _aws_cdk_aws_gamelift_alpha_ScriptAttributes, _aws_cdk_aws_gamelift_alpha_ScriptProps, _aws_cdk_aws_gamelift_alpha_Script, _aws_cdk_aws_gamelift_alpha_AutoScalingPolicy, _aws_cdk_aws_gamelift_alpha_InstanceDefinition, _aws_cdk_aws_gamelift_alpha_DeleteOption, _aws_cdk_aws_gamelift_alpha_BalancingStrategy, _aws_cdk_aws_gamelift_alpha_IGameServerGroup, _aws_cdk_aws_gamelift_alpha_GameServerGroupBase, _aws_cdk_aws_gamelift_alpha_GameServerGroupAttributes, _aws_cdk_aws_gamelift_alpha_GameServerGroupProps, _aws_cdk_aws_gamelift_alpha_GameServerGroup, _aws_cdk_aws_gamelift_alpha_Protocol, _aws_cdk_aws_gamelift_alpha_PortProps, _aws_cdk_aws_gamelift_alpha_Port, _aws_cdk_aws_gamelift_alpha_IPeer, _aws_cdk_aws_gamelift_alpha_Peer, _aws_cdk_aws_gamelift_alpha_IngressRule, _aws_cdk_aws_gamelift_alpha_LocationCapacity, _aws_cdk_aws_gamelift_alpha_Location, _aws_cdk_aws_gamelift_alpha_ServerProcess, _aws_cdk_aws_gamelift_alpha_RuntimeConfiguration, _aws_cdk_aws_gamelift_alpha_ResourceCreationLimitPolicy, _aws_cdk_aws_gamelift_alpha_IFleet, _aws_cdk_aws_gamelift_alpha_FleetProps, _aws_cdk_aws_gamelift_alpha_FleetAttributes, _aws_cdk_aws_gamelift_alpha_FleetBase, _aws_cdk_aws_gamelift_alpha_IBuildFleet, _aws_cdk_aws_gamelift_alpha_BuildFleetProps, _aws_cdk_aws_gamelift_alpha_BuildFleet };
|
package/README.md
CHANGED
|
@@ -46,13 +46,6 @@ configuration or game server fleet management system.
|
|
|
46
46
|
|
|
47
47
|
## GameLift Hosting
|
|
48
48
|
|
|
49
|
-
### Defining a GameLift Fleet
|
|
50
|
-
|
|
51
|
-
GameLift helps you deploy, operate, and scale dedicated game servers for
|
|
52
|
-
session-based multiplayer games. It helps you regulate the resources needed to
|
|
53
|
-
host your games, finds available game servers to host new game sessions, and
|
|
54
|
-
puts players into games.
|
|
55
|
-
|
|
56
49
|
### Uploading builds and scripts to GameLift
|
|
57
50
|
|
|
58
51
|
Before deploying your GameLift-enabled multiplayer game servers for hosting with the GameLift service, you need to upload
|
|
@@ -103,3 +96,420 @@ new gamelift.Script(this, 'Script', {
|
|
|
103
96
|
content: gamelift.Content.fromBucket(bucket, "sample-asset-key")
|
|
104
97
|
});
|
|
105
98
|
```
|
|
99
|
+
|
|
100
|
+
### Defining a GameLift Fleet
|
|
101
|
+
|
|
102
|
+
#### Creating a custom game server fleet
|
|
103
|
+
|
|
104
|
+
Your uploaded game servers are hosted on GameLift virtual computing resources,
|
|
105
|
+
called instances. You set up your hosting resources by creating a fleet of
|
|
106
|
+
instances and deploying them to run your game servers. You can design a fleet
|
|
107
|
+
to fit your game's needs.
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
new gamelift.BuildFleet(this, 'Game server fleet', {
|
|
111
|
+
fleetName: 'test-fleet',
|
|
112
|
+
content: gamelift.Build.fromAsset(this, 'Build', path.join(__dirname, 'CustomerGameServer')),
|
|
113
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE),
|
|
114
|
+
runtimeConfiguration: {
|
|
115
|
+
serverProcesses: [{
|
|
116
|
+
launchPath: 'test-launch-path',
|
|
117
|
+
}],
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Managing game servers launch configuration
|
|
123
|
+
|
|
124
|
+
GameLift uses a fleet's runtime configuration to determine the type and number
|
|
125
|
+
of processes to run on each instance in the fleet. At a minimum, a runtime
|
|
126
|
+
configuration contains one server process configuration that represents one
|
|
127
|
+
game server executable. You can also define additional server process
|
|
128
|
+
configurations to run other types of processes related to your game. Each
|
|
129
|
+
server process configuration contains the following information:
|
|
130
|
+
|
|
131
|
+
* The file name and path of an executable in your game build.
|
|
132
|
+
|
|
133
|
+
* Optionally Parameters to pass to the process on launch.
|
|
134
|
+
|
|
135
|
+
* The number of processes to run concurrently.
|
|
136
|
+
|
|
137
|
+
A GameLift instance is limited to 50 processes running concurrently.
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
declare const build: gamelift.Build;
|
|
141
|
+
// Server processes can be delcared in a declarative way through the constructor
|
|
142
|
+
const fleet = new gamelift.BuildFleet(this, 'Game server fleet', {
|
|
143
|
+
fleetName: 'test-fleet',
|
|
144
|
+
content: build,
|
|
145
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE),
|
|
146
|
+
runtimeConfiguration: {
|
|
147
|
+
serverProcesses: [{
|
|
148
|
+
launchPath: '/local/game/GameLiftExampleServer.x86_64',
|
|
149
|
+
parameters: '-logFile /local/game/logs/myserver1935.log -port 1935',
|
|
150
|
+
concurrentExecutions: 100,
|
|
151
|
+
}]
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
See [Managing how game servers are launched for hosting](https://docs.aws.amazon.com/gamelift/latest/developerguide/fleets-multiprocess.html)
|
|
157
|
+
in the *Amazon GameLift Developer Guide*.
|
|
158
|
+
|
|
159
|
+
### Defining an instance type
|
|
160
|
+
|
|
161
|
+
GameLift uses Amazon Elastic Compute Cloud (Amazon EC2) resources, called
|
|
162
|
+
instances, to deploy your game servers and host game sessions for your players.
|
|
163
|
+
When setting up a new fleet, you decide what type of instances your game needs
|
|
164
|
+
and how to run game server processes on them (using a runtime configuration). All instances in a fleet use the same type of resources and the same runtime
|
|
165
|
+
configuration. You can edit a fleet's runtime configuration and other fleet
|
|
166
|
+
properties, but the type of resources cannot be changed.
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
declare const build: gamelift.Build;
|
|
170
|
+
new gamelift.BuildFleet(this, 'Game server fleet', {
|
|
171
|
+
fleetName: 'test-fleet',
|
|
172
|
+
content: build,
|
|
173
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE),
|
|
174
|
+
runtimeConfiguration: {
|
|
175
|
+
serverProcesses: [{
|
|
176
|
+
launchPath: '/local/game/GameLiftExampleServer.x86_64',
|
|
177
|
+
}]
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Using Spot instances
|
|
183
|
+
|
|
184
|
+
When setting up your hosting resources, you have the option of using Spot
|
|
185
|
+
Instances, On-Demand Instances, or a combination.
|
|
186
|
+
|
|
187
|
+
By default, fleet are using on demand capacity.
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
declare const build: gamelift.Build;
|
|
191
|
+
new gamelift.BuildFleet(this, 'Game server fleet', {
|
|
192
|
+
fleetName: 'test-fleet',
|
|
193
|
+
content: build,
|
|
194
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE),
|
|
195
|
+
runtimeConfiguration: {
|
|
196
|
+
serverProcesses: [{
|
|
197
|
+
launchPath: '/local/game/GameLiftExampleServer.x86_64',
|
|
198
|
+
}]
|
|
199
|
+
},
|
|
200
|
+
useSpot: true
|
|
201
|
+
});
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Allowing Ingress traffic
|
|
205
|
+
|
|
206
|
+
The allowed IP address ranges and port settings that allow inbound traffic to
|
|
207
|
+
access game sessions on this fleet.
|
|
208
|
+
|
|
209
|
+
New game sessions are assigned an IP address/port number combination, which
|
|
210
|
+
must fall into the fleet's allowed ranges. Fleets with custom game builds must
|
|
211
|
+
have permissions explicitly set. For Realtime Servers fleets, GameLift
|
|
212
|
+
automatically opens two port ranges, one for TCP messaging and one for UDP.
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
declare const build: gamelift.Build;
|
|
216
|
+
|
|
217
|
+
const fleet = new gamelift.BuildFleet(this, 'Game server fleet', {
|
|
218
|
+
fleetName: 'test-fleet',
|
|
219
|
+
content: build,
|
|
220
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE),
|
|
221
|
+
runtimeConfiguration: {
|
|
222
|
+
serverProcesses: [{
|
|
223
|
+
launchPath: '/local/game/GameLiftExampleServer.x86_64',
|
|
224
|
+
}]
|
|
225
|
+
},
|
|
226
|
+
ingressRules: [{
|
|
227
|
+
source: gamelift.Peer.anyIpv4(),
|
|
228
|
+
port: gamelift.Port.tcpRange(100, 200),
|
|
229
|
+
}]
|
|
230
|
+
});
|
|
231
|
+
// Allowing a specific CIDR for port 1111 on UDP Protocol
|
|
232
|
+
fleet.addIngressRule(gamelift.Peer.ipv4('1.2.3.4/32'), gamelift.Port.udp(1111));
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Managing locations
|
|
236
|
+
|
|
237
|
+
A single Amazon GameLift fleet has a home Region by default (the Region you
|
|
238
|
+
deploy it to), but it can deploy resources to any number of GameLift supported
|
|
239
|
+
Regions. Select Regions based on where your players are located and your
|
|
240
|
+
latency needs.
|
|
241
|
+
|
|
242
|
+
By default, home region is used as default location but we can add new locations if needed and define desired capacity
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
declare const build: gamelift.Build;
|
|
246
|
+
|
|
247
|
+
// Locations can be added directly through constructor
|
|
248
|
+
const fleet = new gamelift.BuildFleet(this, 'Game server fleet', {
|
|
249
|
+
fleetName: 'test-fleet',
|
|
250
|
+
content: build,
|
|
251
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE),
|
|
252
|
+
runtimeConfiguration: {
|
|
253
|
+
serverProcesses: [{
|
|
254
|
+
launchPath: '/local/game/GameLiftExampleServer.x86_64',
|
|
255
|
+
}]
|
|
256
|
+
},
|
|
257
|
+
locations: [ {
|
|
258
|
+
region: 'eu-west-1',
|
|
259
|
+
capacity: {
|
|
260
|
+
desiredCapacity: 5,
|
|
261
|
+
minSize: 2,
|
|
262
|
+
maxSize: 10
|
|
263
|
+
}
|
|
264
|
+
}, {
|
|
265
|
+
region: 'us-east-1',
|
|
266
|
+
capacity: {
|
|
267
|
+
desiredCapacity: 5,
|
|
268
|
+
minSize: 2,
|
|
269
|
+
maxSize: 10
|
|
270
|
+
}
|
|
271
|
+
}]
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// Or through dedicated methods
|
|
275
|
+
fleet.addLocation('ap-southeast-1', 5, 2, 10);
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Specifying an IAM role for a Fleet
|
|
279
|
+
|
|
280
|
+
Some GameLift features require you to extend limited access to your AWS
|
|
281
|
+
resources. This is done by creating an AWS IAM role. The GameLift Fleet class
|
|
282
|
+
automatically created an IAM role with all the minimum necessary permissions
|
|
283
|
+
for GameLift to access your ressources. If you wish, you may
|
|
284
|
+
specify your own IAM role.
|
|
285
|
+
|
|
286
|
+
```ts
|
|
287
|
+
declare const build: gamelift.Build;
|
|
288
|
+
const role = new iam.Role(this, 'Role', {
|
|
289
|
+
assumedBy: new iam.CompositePrincipal(new iam.ServicePrincipal('gamelift.amazonaws.com'))
|
|
290
|
+
});
|
|
291
|
+
role.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('CloudWatchAgentServerPolicy'));
|
|
292
|
+
|
|
293
|
+
const fleet = new gamelift.BuildFleet(this, 'Game server fleet', {
|
|
294
|
+
fleetName: 'test-fleet',
|
|
295
|
+
content: build,
|
|
296
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE),
|
|
297
|
+
runtimeConfiguration: {
|
|
298
|
+
serverProcesses: [{
|
|
299
|
+
launchPath: '/local/game/GameLiftExampleServer.x86_64',
|
|
300
|
+
}]
|
|
301
|
+
},
|
|
302
|
+
role: role
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
// Actions can also be grantted through dedicated method
|
|
306
|
+
fleet.grant(role, 'gamelift:ListFleets');
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Monitoring your Fleet
|
|
310
|
+
|
|
311
|
+
GameLift is integrated with CloudWatch, so you can monitor the performance of
|
|
312
|
+
your game servers via logs and metrics.
|
|
313
|
+
|
|
314
|
+
#### Metrics
|
|
315
|
+
|
|
316
|
+
GameLift Fleet sends metrics to CloudWatch so that you can collect and analyze
|
|
317
|
+
the activity of your Fleet, including game and player sessions and server
|
|
318
|
+
processes.
|
|
319
|
+
|
|
320
|
+
You can then use CloudWatch alarms to alert you, for example, when matches has
|
|
321
|
+
been rejected (potential matches that were rejected by at least one player
|
|
322
|
+
since the last report) exceed a certain thresold which could means that you may
|
|
323
|
+
have an issue in your matchmaking rules.
|
|
324
|
+
|
|
325
|
+
CDK provides methods for accessing GameLift Fleet metrics with default configuration,
|
|
326
|
+
such as `metricActiveInstances`, or `metricIdleInstances` (see [`IFleet`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-gamelift.IFleet.html)
|
|
327
|
+
for a full list). CDK also provides a generic `metric` method that can be used
|
|
328
|
+
to produce metric configurations for any metric provided by GameLift Fleet,
|
|
329
|
+
Game sessions or server processes; the configurations are pre-populated with
|
|
330
|
+
the correct dimensions for the matchmaking configuration.
|
|
331
|
+
|
|
332
|
+
```ts
|
|
333
|
+
declare const fleet: gamelift.BuildFleet;
|
|
334
|
+
// Alarm that triggers when the per-second average of not used instances exceed 10%
|
|
335
|
+
const instancesUsedRatio = new cloudwatch.MathExpression({
|
|
336
|
+
expression: '1 - (activeInstances / idleInstances)',
|
|
337
|
+
usingMetrics: {
|
|
338
|
+
activeInstances: fleet.metric('ActiveInstances', { statistic: cloudwatch.Statistic.SUM }),
|
|
339
|
+
idleInstances: fleet.metricIdleInstances(),
|
|
340
|
+
},
|
|
341
|
+
});
|
|
342
|
+
new cloudwatch.Alarm(this, 'Alarm', {
|
|
343
|
+
metric: instancesUsedRatio,
|
|
344
|
+
threshold: 0.1,
|
|
345
|
+
evaluationPeriods: 3,
|
|
346
|
+
});
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
See: [Monitoring Using CloudWatch Metrics](https://docs.aws.amazon.com/gamelift/latest/developerguide/monitoring-cloudwatch.html)
|
|
350
|
+
in the *Amazon GameLift Developer Guide*.
|
|
351
|
+
|
|
352
|
+
## GameLift FleetIQ
|
|
353
|
+
|
|
354
|
+
The GameLift FleetIQ solution is a game hosting layer that supplements the full
|
|
355
|
+
set of computing resource management tools that you get with Amazon EC2 and
|
|
356
|
+
Auto Scaling. This solution lets you directly manage your Amazon EC2 and Auto
|
|
357
|
+
Scaling resources and integrate as needed with other AWS services.
|
|
358
|
+
|
|
359
|
+
### Defining a Game Server Group
|
|
360
|
+
|
|
361
|
+
When using GameLift FleetIQ, you prepare to launch Amazon EC2 instances as
|
|
362
|
+
usual: make an Amazon Machine Image (AMI) with your game server software,
|
|
363
|
+
create an Amazon EC2 launch template, and define configuration settings for an
|
|
364
|
+
Auto Scaling group. However, instead of creating an Auto Scaling group
|
|
365
|
+
directly, you create a GameLift FleetIQ game server group with your Amazon EC2
|
|
366
|
+
and Auto Scaling resources and configuration. All game server groups must have
|
|
367
|
+
at least two instance types defined for it.
|
|
368
|
+
|
|
369
|
+
Once a game server group and Auto Scaling group are up and running with
|
|
370
|
+
instances deployed, when updating a Game Server Group instance, only certain
|
|
371
|
+
properties in the Auto Scaling group may be overwrite. For all other Auto
|
|
372
|
+
Scaling group properties, such as MinSize, MaxSize, and LaunchTemplate, you can
|
|
373
|
+
modify these directly on the Auto Scaling group using the AWS Console or
|
|
374
|
+
dedicated Api.
|
|
375
|
+
|
|
376
|
+
```ts
|
|
377
|
+
declare const launchTemplate: ec2.ILaunchTemplate;
|
|
378
|
+
declare const vpc: ec2.IVpc;
|
|
379
|
+
|
|
380
|
+
new gamelift.GameServerGroup(this, 'Game server group', {
|
|
381
|
+
gameServerGroupName: 'sample-gameservergroup-name',
|
|
382
|
+
instanceDefinitions: [{
|
|
383
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE),
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE),
|
|
387
|
+
}],
|
|
388
|
+
launchTemplate: launchTemplate,
|
|
389
|
+
vpc: vpc
|
|
390
|
+
});
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
See [Manage game server groups](https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-integrate-gameservergroup.html)
|
|
394
|
+
in the *Amazon GameLift FleetIQ Developer Guide*.
|
|
395
|
+
|
|
396
|
+
### Scaling Policy
|
|
397
|
+
|
|
398
|
+
The scaling policy uses the metric `PercentUtilizedGameServers` to maintain a
|
|
399
|
+
buffer of idle game servers that can immediately accommodate new games and
|
|
400
|
+
players.
|
|
401
|
+
|
|
402
|
+
```ts
|
|
403
|
+
declare const launchTemplate: ec2.ILaunchTemplate;
|
|
404
|
+
declare const vpc: ec2.IVpc;
|
|
405
|
+
|
|
406
|
+
new gamelift.GameServerGroup(this, 'Game server group', {
|
|
407
|
+
gameServerGroupName: 'sample-gameservergroup-name',
|
|
408
|
+
instanceDefinitions: [{
|
|
409
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE),
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE),
|
|
413
|
+
}],
|
|
414
|
+
launchTemplate: launchTemplate,
|
|
415
|
+
vpc: vpc,
|
|
416
|
+
autoScalingPolicy: {
|
|
417
|
+
estimatedInstanceWarmup: Duration.minutes(5),
|
|
418
|
+
targetTrackingConfiguration: 5
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
See [Manage game server groups](https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-integrate-gameservergroup.html)
|
|
424
|
+
in the *Amazon GameLift FleetIQ Developer Guide*.
|
|
425
|
+
|
|
426
|
+
### Specifying an IAM role for GameLift
|
|
427
|
+
|
|
428
|
+
The GameLift FleetIQ class automatically creates an IAM role with all the minimum necessary
|
|
429
|
+
permissions for GameLift to access your Amazon EC2 Auto Scaling groups. If you wish, you may
|
|
430
|
+
specify your own IAM role. It must have the correct permissions, or FleetIQ creation or ressource usage may fail.
|
|
431
|
+
|
|
432
|
+
```ts
|
|
433
|
+
declare const launchTemplate: ec2.ILaunchTemplate;
|
|
434
|
+
declare const vpc: ec2.IVpc;
|
|
435
|
+
|
|
436
|
+
const role = new iam.Role(this, 'Role', {
|
|
437
|
+
assumedBy: new iam.CompositePrincipal(new iam.ServicePrincipal('gamelift.amazonaws.com'),
|
|
438
|
+
new iam.ServicePrincipal('autoscaling.amazonaws.com'))
|
|
439
|
+
});
|
|
440
|
+
role.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('GameLiftGameServerGroupPolicy'));
|
|
441
|
+
|
|
442
|
+
new gamelift.GameServerGroup(this, 'Game server group', {
|
|
443
|
+
gameServerGroupName: 'sample-gameservergroup-name',
|
|
444
|
+
instanceDefinitions: [{
|
|
445
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE),
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE),
|
|
449
|
+
}],
|
|
450
|
+
launchTemplate: launchTemplate,
|
|
451
|
+
vpc: vpc,
|
|
452
|
+
role: role
|
|
453
|
+
});
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
See [Controlling Access](https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-iam-permissions-roles.html)
|
|
457
|
+
in the *Amazon GameLift FleetIQ Developer Guide*.
|
|
458
|
+
|
|
459
|
+
### Specifying VPC Subnets
|
|
460
|
+
|
|
461
|
+
GameLift FleetIQ use by default, all supported GameLift FleetIQ Availability
|
|
462
|
+
Zones in your chosen region. You can override this parameter to specify VPCs
|
|
463
|
+
subnets that you've set up.
|
|
464
|
+
|
|
465
|
+
This property cannot be updated after the game server group is created, and the
|
|
466
|
+
corresponding Auto Scaling group will always use the property value that is set
|
|
467
|
+
with this request, even if the Auto Scaling group is updated directly.
|
|
468
|
+
|
|
469
|
+
```ts
|
|
470
|
+
declare const launchTemplate: ec2.ILaunchTemplate;
|
|
471
|
+
declare const vpc: ec2.IVpc;
|
|
472
|
+
|
|
473
|
+
new gamelift.GameServerGroup(this, 'GameServerGroup', {
|
|
474
|
+
gameServerGroupName: 'sample-gameservergroup-name',
|
|
475
|
+
instanceDefinitions: [{
|
|
476
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE),
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE),
|
|
480
|
+
}],
|
|
481
|
+
launchTemplate: launchTemplate,
|
|
482
|
+
vpc: vpc,
|
|
483
|
+
vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC }
|
|
484
|
+
});
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### Monitoring
|
|
488
|
+
|
|
489
|
+
GameLift FleetIQ sends metrics to CloudWatch so that you can collect and
|
|
490
|
+
analyze the activity of your Game server fleet, including the number of
|
|
491
|
+
utilized game servers, and the number of game server interruption due to
|
|
492
|
+
limited Spot availability.
|
|
493
|
+
|
|
494
|
+
You can then use CloudWatch alarms to alert you, for example, when the portion
|
|
495
|
+
of game servers that are currently supporting game executions exceed a certain
|
|
496
|
+
thresold which could means that your autoscaling policy need to be adjust to
|
|
497
|
+
add more instances to match with player demand.
|
|
498
|
+
|
|
499
|
+
CDK provides a generic `metric` method that can be used
|
|
500
|
+
to produce metric configurations for any metric provided by GameLift FleetIQ;
|
|
501
|
+
the configurations are pre-populated with the correct dimensions for the
|
|
502
|
+
matchmaking configuration.
|
|
503
|
+
|
|
504
|
+
```ts
|
|
505
|
+
declare const gameServerGroup: gamelift.IGameServerGroup;
|
|
506
|
+
// Alarm that triggers when the percent of utilized game servers exceed 90%
|
|
507
|
+
new cloudwatch.Alarm(this, 'Alarm', {
|
|
508
|
+
metric: gameServerGroup.metric('UtilizedGameServers'),
|
|
509
|
+
threshold: 0.9,
|
|
510
|
+
evaluationPeriods: 2,
|
|
511
|
+
});
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
See: [Monitoring with CloudWatch](https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-metrics.html)
|
|
515
|
+
in the *Amazon GameLift FleetIQ Developer Guide*.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
import { IBuild } from './build';
|
|
4
|
+
import { FleetBase, FleetProps, IFleet } from './fleet-base';
|
|
5
|
+
import { Port, IPeer, IngressRule } from './ingress-rule';
|
|
6
|
+
/**
|
|
7
|
+
* Represents a GameLift Fleet used to run a custom game build.
|
|
8
|
+
*/
|
|
9
|
+
export interface IBuildFleet extends IFleet {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Properties for a new Gamelift build fleet
|
|
13
|
+
*/
|
|
14
|
+
export interface BuildFleetProps extends FleetProps {
|
|
15
|
+
/**
|
|
16
|
+
* A build to be deployed on the fleet.
|
|
17
|
+
* The build must have been successfully uploaded to Amazon GameLift and be in a `READY` status.
|
|
18
|
+
*
|
|
19
|
+
* This fleet setting cannot be changed once the fleet is created.
|
|
20
|
+
*/
|
|
21
|
+
readonly content: IBuild;
|
|
22
|
+
/**
|
|
23
|
+
* The allowed IP address ranges and port settings that allow inbound traffic to access game sessions on this fleet.
|
|
24
|
+
*
|
|
25
|
+
* This property must be set before players can connect to game sessions.
|
|
26
|
+
*
|
|
27
|
+
* @default no inbound traffic allowed
|
|
28
|
+
*/
|
|
29
|
+
readonly ingressRules?: IngressRule[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A fleet contains Amazon Elastic Compute Cloud (Amazon EC2) instances that GameLift hosts.
|
|
33
|
+
* A fleet uses the configuration and scaling logic that you define to run your game server build. You can use a fleet directly without a queue.
|
|
34
|
+
* You can also associate multiple fleets with a GameLift queue.
|
|
35
|
+
*
|
|
36
|
+
* For example, you can use Spot Instance fleets configured with your preferred locations, along with a backup On-Demand Instance fleet with the same locations.
|
|
37
|
+
* Using multiple Spot Instance fleets of different instance types reduces the chance of needing On-Demand Instance placement.
|
|
38
|
+
*
|
|
39
|
+
* @resource AWS::GameLift::Fleet
|
|
40
|
+
*/
|
|
41
|
+
export declare class BuildFleet extends FleetBase implements IBuildFleet {
|
|
42
|
+
/**
|
|
43
|
+
* Import an existing fleet from its identifier.
|
|
44
|
+
*/
|
|
45
|
+
static fromBuildFleetId(scope: Construct, id: string, buildFleetId: string): IBuildFleet;
|
|
46
|
+
/**
|
|
47
|
+
* Import an existing fleet from its ARN.
|
|
48
|
+
*/
|
|
49
|
+
static fromBuildFleetArn(scope: Construct, id: string, buildFleetArn: string): IBuildFleet;
|
|
50
|
+
/**
|
|
51
|
+
* The Identifier of the fleet.
|
|
52
|
+
*/
|
|
53
|
+
readonly fleetId: string;
|
|
54
|
+
/**
|
|
55
|
+
* The ARN of the fleet.
|
|
56
|
+
*/
|
|
57
|
+
readonly fleetArn: string;
|
|
58
|
+
/**
|
|
59
|
+
* The build content of the fleet
|
|
60
|
+
*/
|
|
61
|
+
readonly content: IBuild;
|
|
62
|
+
/**
|
|
63
|
+
* The IAM role GameLift assumes by fleet instances to access AWS ressources.
|
|
64
|
+
*/
|
|
65
|
+
readonly role: iam.IRole;
|
|
66
|
+
/**
|
|
67
|
+
* The principal this GameLift fleet is using.
|
|
68
|
+
*/
|
|
69
|
+
readonly grantPrincipal: iam.IPrincipal;
|
|
70
|
+
private readonly ingressRules;
|
|
71
|
+
constructor(scope: Construct, id: string, props: BuildFleetProps);
|
|
72
|
+
/**
|
|
73
|
+
* Adds an ingress rule to allow inbound traffic to access game sessions on this fleet.
|
|
74
|
+
*
|
|
75
|
+
* @param source A range of allowed IP addresses
|
|
76
|
+
* @param port The port range used for ingress traffic
|
|
77
|
+
*/
|
|
78
|
+
addIngressRule(source: IPeer, port: Port): void;
|
|
79
|
+
private addInternalIngressRule;
|
|
80
|
+
private parseIngressRules;
|
|
81
|
+
}
|