diff --git a/packages/@aws-cdk/aws-gamelift/README.md b/packages/@aws-cdk/aws-gamelift/README.md index 48a572920d223..8a1fb958781d2 100644 --- a/packages/@aws-cdk/aws-gamelift/README.md +++ b/packages/@aws-cdk/aws-gamelift/README.md @@ -109,3 +109,168 @@ new gamelift.Script(this, 'Script', { content: gamelift.Content.fromBucket(bucket, "sample-asset-key") }); ``` + +## GameLift FleetIQ + +The GameLift FleetIQ solution is a game hosting layer that supplements the full +set of computing resource management tools that you get with Amazon EC2 and +Auto Scaling. This solution lets you directly manage your Amazon EC2 and Auto +Scaling resources and integrate as needed with other AWS services. + +### Defining a Game Server Group + +When using GameLift FleetIQ, you prepare to launch Amazon EC2 instances as +usual: make an Amazon Machine Image (AMI) with your game server software, +create an Amazon EC2 launch template, and define configuration settings for an +Auto Scaling group. However, instead of creating an Auto Scaling group +directly, you create a GameLift FleetIQ game server group with your Amazon EC2 +and Auto Scaling resources and configuration. All game server groups must have +at least two instance types defined for it. + +Once a game server group and Auto Scaling group are up and running with +instances deployed, when updating a Game Server Group instance, only certain +properties in the Auto Scaling group may be overwrite. For all other Auto +Scaling group properties, such as MinSize, MaxSize, and LaunchTemplate, you can +modify these directly on the Auto Scaling group using the AWS Console or +dedicated Api. + +```ts +declare const launchTemplate: ec2.ILaunchTemplate; +declare const vpc: ec2.IVpc; + +new gamelift.GameServerGroup(this, 'Game server group', { + gameServerGroupName: 'sample-gameservergroup-name', + instanceDefinitions: [{ + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE), + }, + { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE), + }], + launchTemplate: launchTemplate, + vpc: vpc +}); +``` + +See [Manage game server groups](https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-integrate-gameservergroup.html) +in the *Amazon GameLift FleetIQ Developer Guide*. + +### Scaling Policy + +The scaling policy uses the metric `PercentUtilizedGameServers` to maintain a +buffer of idle game servers that can immediately accommodate new games and +players. + +```ts +declare const launchTemplate: ec2.ILaunchTemplate; +declare const vpc: ec2.IVpc; + +new gamelift.GameServerGroup(this, 'Game server group', { + gameServerGroupName: 'sample-gameservergroup-name', + instanceDefinitions: [{ + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE), + }, + { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE), + }], + launchTemplate: launchTemplate, + vpc: vpc, + autoScalingPolicy: { + estimatedInstanceWarmup: Duration.minutes(5), + targetTrackingConfiguration: 5 + } +}); +``` + +See [Manage game server groups](https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-integrate-gameservergroup.html) +in the *Amazon GameLift FleetIQ Developer Guide*. + +### Specifying an IAM role + +The GameLift FleetIQ class automatically creates an IAM role with all the minimum necessary +permissions for GameLift to access your Amazon EC2 Auto Scaling groups. If you wish, you may +specify your own IAM role. It must have the correct permissions, or FleetIQ creation or ressource usage may fail. + +```ts +declare const launchTemplate: ec2.ILaunchTemplate; +declare const vpc: ec2.IVpc; + +const role = new iam.Role(this, 'Role', { + assumedBy: new iam.CompositePrincipal(new iam.ServicePrincipal('gamelift.amazonaws.com'), + new iam.ServicePrincipal('autoscaling.amazonaws.com')) +}); +role.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('GameLiftGameServerGroupPolicy')); + +new gamelift.GameServerGroup(this, 'Game server group', { + gameServerGroupName: 'sample-gameservergroup-name', + instanceDefinitions: [{ + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE), + }, + { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE), + }], + launchTemplate: launchTemplate, + vpc: vpc, + role: role +}); +``` + +See [Controlling Access](https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-iam-permissions-roles.html) +in the *Amazon GameLift FleetIQ Developer Guide*. + +### Specifying VPC Subnets + +GameLift FleetIQ use by default, all supported GameLift FleetIQ Availability +Zones in your chosen region. You can override this parameter to specify VPCs +subnets that you've set up. + +This property cannot be updated after the game server group is created, and the +corresponding Auto Scaling group will always use the property value that is set +with this request, even if the Auto Scaling group is updated directly. + +```ts +declare const launchTemplate: ec2.ILaunchTemplate; +declare const vpc: ec2.IVpc; + +new gamelift.GameServerGroup(this, 'GameServerGroup', { + gameServerGroupName: 'sample-gameservergroup-name', + instanceDefinitions: [{ + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE), + }, + { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE), + }], + launchTemplate: launchTemplate, + vpc: vpc, + vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC } +}); +``` + +### Monitoring + +GameLift FleetIQ sends metrics to CloudWatch so that you can collect and +analyze the activity of your Game server fleet, including the number of +utilized game servers, and the number of game server interruption due to +limited Spot availability. + +You can then use CloudWatch alarms to alert you, for example, when the portion +of game servers that are currently supporting game executions exceed a certain +thresold which could means that your autoscaling policy need to be adjust to +add more instances to match with player demand. + +CDK provides a generic `metric` method that can be used +to produce metric configurations for any metric provided by GameLift FleetIQ; +the configurations are pre-populated with the correct dimensions for the +matchmaking configuration. + +```ts +declare const gameServerGroup: gamelift.IGameServerGroup; +// Alarm that triggers when the percent of utilized game servers exceed 90% +new cloudwatch.Alarm(this, 'Alarm', { + metric: gameServerGroup.metric('UtilizedGameServers'), + threshold: 0.9, + evaluationPeriods: 2, +}); +``` + +See: [Monitoring with CloudWatch](https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-metrics.html) +in the *Amazon GameLift FleetIQ Developer Guide*. diff --git a/packages/@aws-cdk/aws-gamelift/lib/game-server-group.ts b/packages/@aws-cdk/aws-gamelift/lib/game-server-group.ts new file mode 100644 index 0000000000000..a212815c8c5b0 --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/lib/game-server-group.ts @@ -0,0 +1,527 @@ +import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; +import * as ec2 from '@aws-cdk/aws-ec2'; +import * as iam from '@aws-cdk/aws-iam'; +import * as cdk from '@aws-cdk/core'; +import { Construct } from 'constructs'; +import { CfnGameServerGroup } from './gamelift.generated'; + + +/** + * Configuration settings for intelligent automatic scaling that uses target tracking. + * After the Auto Scaling group is created, all updates to Auto Scaling policies, including changing this policy and adding or removing other policies, is done directly on the Auto Scaling group. + */ +export interface AutoScalingPolicy { + /** + * Length of time, it takes for a new instance to start new game server processes and register with GameLift FleetIQ. + * Specifying a warm-up time can be useful, particularly with game servers that take a long time to start up, because it avoids prematurely starting new instances. + * + * @default no instance warmup duration settled + */ + readonly estimatedInstanceWarmup?: cdk.Duration; + + /** + * Settings for a target-based scaling policy applied to Auto Scaling group. + * These settings are used to create a target-based policy that tracks the GameLift FleetIQ metric `PercentUtilizedGameServers` and specifies a target value for the metric. + * + * As player usage changes, the policy triggers to adjust the game server group capacity so that the metric returns to the target value. + */ + readonly targetTrackingConfiguration: number; + +} +/** + * An allowed instance type for a game server group. + * All game server groups must have at least two instance types defined for it. + * GameLift FleetIQ periodically evaluates each defined instance type for viability. + * It then updates the Auto Scaling group with the list of viable instance types. + */ +export interface InstanceDefinition { + /** + * An Amazon EC2 instance type designation. + */ + readonly instanceType: ec2.InstanceType; + /** + * Instance weighting that indicates how much this instance type contributes to the total capacity of a game server group. + * Instance weights are used by GameLift FleetIQ to calculate the instance type's cost per unit hour and better identify the most cost-effective options. + * + * @see https://docs.aws.amazon.com/autoscaling/ec2/userguide/asg-instance-weighting.html + * + * @default default value is 1 + */ + readonly weight?: number; +} +/** + * The type of delete to perform. + * To delete a game server group, specify the DeleteOption. + */ +export enum DeleteOption { + /** + * Terminates the game server group and Amazon EC2 Auto Scaling group only when it has no game servers that are in UTILIZED status. + */ + SAFE_DELETE = 'SAFE_DELETE', + /** + * Terminates the game server group, including all active game servers regardless of their utilization status, and the Amazon EC2 Auto Scaling group. + */ + FORCE_DELETE = 'FORCE_DELETE', + /** + * Does a safe delete of the game server group but retains the Amazon EC2 Auto Scaling group as is. + */ + RETAIN = 'RETAIN', +} +/** + * Indicates how GameLift FleetIQ balances the use of Spot Instances and On-Demand Instances in the game server group. + */ +export enum BalancingStrategy { + /** + * Only Spot Instances are used in the game server group. + * If Spot Instances are unavailable or not viable for game hosting, the game server group provides no hosting capacity until Spot Instances can again be used. + * Until then, no new instances are started, and the existing nonviable Spot Instances are terminated (after current gameplay ends) and are not replaced. + */ + SPOT_ONLY = 'SPOT_ONLY', + /** + * Spot Instances are used whenever available in the game server group. + * If Spot Instances are unavailable, the game server group continues to provide hosting capacity by falling back to On-Demand Instances. + * Existing nonviable Spot Instances are terminated (after current gameplay ends) and are replaced with new On-Demand Instances. + */ + SPOT_PREFERRED = 'SPOT_PREFERRED', + /** + * Only On-Demand Instances are used in the game server group. + * No Spot Instances are used, even when available, while this balancing strategy is in force. + */ + ON_DEMAND_ONLY = 'ON_DEMAND_ONLY', + +} +/** + * Represent a GameLift FleetIQ game server group. + */ +export interface IGameServerGroup extends cdk.IResource, iam.IGrantable { + /** + * The ARN of the game server group. + * + * @attribute + */ + readonly gameServerGroupArn: string; + + /** + * The ARN of the generated AutoScaling group + * + * @attribute + */ + readonly autoScalingGroupArn: string; + + /** + * The name of the game server group + * + * @attribute + */ + readonly gameServerGroupName: string; + + /** + * Grant the `grantee` identity permissions to perform `actions`. + */ + grant(grantee: iam.IGrantable, ...actions: string[]): iam.Grant; + + /** + * Return the given named metric for this fleet. + */ + metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric; +} + +/** + * Base class for new and imported GameLift FleetIQ game server group. + */ +export abstract class GameServerGroupBase extends cdk.Resource implements IGameServerGroup { + + /** + * The ARN of the game server group. + */ + public abstract readonly gameServerGroupArn: string; + + /** + * The ARN of the generated AutoScaling group + */ + public abstract readonly autoScalingGroupArn: string; + + /** + * The name of the game server group. + */ + public abstract readonly gameServerGroupName: string; + + /** + * The principal this GameLift game server group is using. + */ + public abstract readonly grantPrincipal: iam.IPrincipal; + + public grant(grantee: iam.IGrantable, ...actions: string[]): iam.Grant { + return iam.Grant.addToPrincipal({ + resourceArns: [this.gameServerGroupArn], + grantee: grantee, + actions: actions, + }); + } + + public metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric { + return new cloudwatch.Metric({ + namespace: 'AWS/GameLift', + metricName: metricName, + dimensionsMap: { + GameServerGroupArn: this.gameServerGroupArn, + }, + ...props, + }).attachTo(this); + } + +} + +/** + * Represents a GameServerGroup content defined outside of this stack. + */ +export interface GameServerGroupAttributes { + + /** + * The name of the game server group + * + * At least one of `gameServerGroupArn` and `gameServerGroupName` must be provided. + * + * @default derived from `gameServerGroupArn`. + */ + readonly gameServerGroupName?: string; + /** + * The ARN of the game server group + * + * At least one of `gameServerGroupArn` and `gameServerGroupName` must be provided. + * + * @default derived from `gameServerGroupName`. + */ + readonly gameServerGroupArn?: string; + + /** + * The ARN of the generated AutoScaling group + * + * @default the imported game server group does not have autoscaling group information + */ + readonly autoScalingGroupArn: string; + + /** + * The IAM role that allows Amazon GameLift to access your Amazon EC2 Auto Scaling groups. + * + * @default the imported game server group cannot be granted access to other resources as an `iam.IGrantable`. + */ + readonly role?: iam.IRole; +} + +/** + * Properties for a new Gamelift FleetIQ Game server group + */ +export interface GameServerGroupProps { + /** + * A developer-defined identifier for the game server group. + * The name is unique for each Region in each AWS account. + */ + readonly gameServerGroupName: string; + + /** + * The IAM role that allows Amazon GameLift to access your Amazon EC2 Auto Scaling groups. + * + * @see https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-iam-permissions-roles.html + * + * @default - a role will be created with default trust to Gamelift and Autoscaling service principal with a default policy `GameLiftGameServerGroupPolicy` attached. + */ + readonly role?: iam.IRole; + + /** + * The minimum number of instances allowed in the Amazon EC2 Auto Scaling group. + * During automatic scaling events, GameLift FleetIQ and Amazon EC2 do not scale down the group below this minimum. + * + * In production, this value should be set to at least 1. + * + * After the Auto Scaling group is created, update this value directly in the Auto Scaling group using the AWS console or APIs. + * + * @default the default is 0 + */ + readonly minSize?: number; + + /** + * The maximum number of instances allowed in the Amazon EC2 Auto Scaling group. During automatic scaling events, GameLift FleetIQ and EC2 do not scale up the group above this maximum. + * + * After the Auto Scaling group is created, update this value directly in the Auto Scaling group using the AWS console or APIs. + * + * @default the default is 1 + */ + readonly maxSize?: number; + + /** + * The VPC network to place the game server group in. + * + * By default, all GameLift FleetIQ-supported Availability Zones are used. + * + * You can use this parameter to specify VPCs that you've set up. + * + * This property cannot be updated after the game server group is created, + * and the corresponding Auto Scaling group will always use the property value that is set with this request, + * even if the Auto Scaling group is updated directly. + */ + readonly vpc: ec2.IVpc; + + /** + * Game server group subnet selection + * + * @default all GameLift FleetIQ-supported Availability Zones are used. + */ + readonly vpcSubnets?: ec2.SubnetSelection; + + /** + * The set of Amazon EC2 instance types that GameLift FleetIQ can use when balancing and automatically scaling instances in the corresponding Auto Scaling group. + */ + readonly instanceDefinitions: InstanceDefinition[]; + + /** + * The Amazon EC2 launch template that contains configuration settings and game server code to be deployed to all instances in the game server group. + * After the Auto Scaling group is created, update this value directly in the Auto Scaling group using the AWS console or APIs. + * + * NOTE: + * If you specify network interfaces in your launch template, you must explicitly set the property AssociatePublicIpAddress to `true`. + * If no network interface is specified in the launch template, GameLift FleetIQ uses your account's default VPC. + * + * @see https://docs.aws.amazon.com/autoscaling/ec2/userguide/create-launch-template.html + */ + readonly launchTemplate: ec2.ILaunchTemplate; + + /** + * A flag that indicates whether instances in the game server group are protected from early termination. + * Unprotected instances that have active game servers running might be terminated during a scale-down event, causing players to be dropped from the game. + * Protected instances cannot be terminated while there are active game servers running except in the event of a forced game server group deletion. + * + * An exception to this is with Spot Instances, which can be terminated by AWS regardless of protection status. + * + * @default game servers running might be terminated during a scale-down event + */ + readonly protectGameServer?: boolean; + + /** + * Configuration settings to define a scaling policy for the Auto Scaling group that is optimized for game hosting. + * The scaling policy uses the metric `PercentUtilizedGameServers` to maintain a buffer of idle game servers that can immediately accommodate new games and players. + * + * After the Auto Scaling group is created, update this value directly in the Auto Scaling group using the AWS console or APIs. + * + * @default no autoscaling policy settled + */ + readonly autoScalingPolicy?: AutoScalingPolicy; + + /** + * The type of delete to perform. To delete a game server group, specify the DeleteOption + * + * @default SAFE_DELETE + */ + readonly deleteOption?: DeleteOption; + + /** + * Indicates how GameLift FleetIQ balances the use of Spot Instances and On-Demand Instances in the game server group. + * + * @default SPOT_PREFERRED + */ + readonly balancingStrategy?: BalancingStrategy; +} + +/** + * Creates a GameLift FleetIQ game server group for managing game hosting on a collection of Amazon EC2 instances for game hosting. + * This operation creates the game server group, creates an Auto Scaling group in your AWS account, and establishes a link between the two groups. + * You can view the status of your game server groups in the GameLift console. + * Game server group metrics and events are emitted to Amazon CloudWatch. + * Before creating a new game server group, you must have the following: + * - An Amazon EC2 launch template that specifies how to launch Amazon EC2 instances with your game server build. + * - An IAM role that extends limited access to your AWS account to allow GameLift FleetIQ to create and interact with the Auto Scaling group. + * + * To create a new game server group, specify a unique group name, IAM role and Amazon EC2 launch template, and provide a list of instance types that can be used in the group. + * You must also set initial maximum and minimum limits on the group's instance count. + * You can optionally set an Auto Scaling policy with target tracking based on a GameLift FleetIQ metric. + * + * Once the game server group and corresponding Auto Scaling group are created, you have full access to change the Auto Scaling group's configuration as needed. + * Several properties that are set when creating a game server group, including maximum/minimum size and auto-scaling policy settings, must be updated directly in the Auto Scaling group. + * Keep in mind that some Auto Scaling group properties are periodically updated by GameLift FleetIQ as part of its balancing activities to optimize for availability and cost. + * + * @see https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-intro.html + * + * @resource AWS::GameLift::GameServerGroup + */ +export class GameServerGroup extends GameServerGroupBase { + + /** + * Import an existing game server group from its attributes. + */ + static fromGameServerGroupAttributes(scope: Construct, id: string, attrs: GameServerGroupAttributes): IGameServerGroup { + if (!attrs.gameServerGroupArn && !attrs.gameServerGroupName) { + throw new Error('Either gameServerGroupName or gameServerGroupArn must be provided in GameServerGroupAttributes'); + } + const gameServerGroupName = attrs.gameServerGroupName ?? + cdk.Stack.of(scope).splitArn(attrs.gameServerGroupArn!, cdk.ArnFormat.SLASH_RESOURCE_NAME).resourceName; + + if (!gameServerGroupName) { + throw new Error(`No game server group name found in ARN: '${attrs.gameServerGroupArn}'`); + } + + const gameServerGroupArn = attrs.gameServerGroupArn ?? cdk.Stack.of(scope).formatArn({ + service: 'gamelift', + resource: 'gameservergroup', + resourceName: attrs.gameServerGroupName, + arnFormat: cdk.ArnFormat.SLASH_RESOURCE_NAME, + }); + + class Import extends GameServerGroupBase { + public readonly gameServerGroupName = gameServerGroupName!; + public readonly gameServerGroupArn = gameServerGroupArn; + public readonly autoScalingGroupArn = attrs.autoScalingGroupArn; + public readonly grantPrincipal = attrs.role ?? new iam.UnknownPrincipal({ resource: this }); + public readonly role = attrs.role; + + constructor(s: Construct, i: string) { + super(s, i, { + environmentFromArn: gameServerGroupArn, + }); + } + } + return new Import(scope, id); + } + + /** + * The name of the game server group + */ + public readonly gameServerGroupName: string; + + /** + * The ARN of the game server group. + */ + public readonly gameServerGroupArn: string; + + /** + * The ARN of the generated AutoScaling group + */ + public readonly autoScalingGroupArn: string; + + /** + * The IAM role that allows Amazon GameLift to access your Amazon EC2 Auto Scaling groups. + */ + public readonly role: iam.IRole; + + /** + * The principal this GameLift game server group is using. + */ + public readonly grantPrincipal: iam.IPrincipal; + + /** + * The VPC network to place the game server group in. + */ + public readonly vpc: ec2.IVpc; + + /** + * The game server group's subnets. + */ + public readonly vpcSubnets?: ec2.SubnetSelection; + + constructor(scope: Construct, id: string, props: GameServerGroupProps) { + super(scope, id, { + physicalName: props.gameServerGroupName, + }); + + if (!cdk.Token.isUnresolved(props.gameServerGroupName)) { + if (props.gameServerGroupName.length > 128) { + throw new Error(`GameServerGroup name can not be longer than 128 characters but has ${props.gameServerGroupName.length} characters.`); + } + + if (!/^[a-zA-Z0-9-\.]+$/.test(props.gameServerGroupName)) { + throw new Error(`Game server group name ${props.gameServerGroupName} can contain only letters, numbers, hyphens, back slash or dot with no spaces.`); + } + } + + this.vpc = props.vpc; + this.vpcSubnets = props.vpcSubnets ?? { subnetType: ec2.SubnetType.PUBLIC }; + const { subnetIds } = props.vpc.selectSubnets(this.vpcSubnets); + + if (props.minSize && props.minSize < 0) { + throw new Error(`The minimum number of instances allowed in the Amazon EC2 Auto Scaling group cannot be lower than 0, given ${props.minSize}`); + } + + if (props.maxSize && props.maxSize < 1) { + throw new Error(`The maximum number of instances allowed in the Amazon EC2 Auto Scaling group cannot be lower than 1, given ${props.maxSize}`); + } + + if (subnetIds.length > 20) { + throw new Error(`No more than 20 subnets are allowed per game server group, given ${subnetIds.length}`); + } + + // Add all instance definitions + if (props.instanceDefinitions.length > 20) { + throw new Error(`No more than 20 instance definitions are allowed per game server group, given ${props.instanceDefinitions.length}`); + } + + this.role = props.role ?? new iam.Role(this, 'ServiceRole', { + assumedBy: new iam.CompositePrincipal( + new iam.ServicePrincipal('gamelift.amazonaws.com'), + new iam.ServicePrincipal('autoscaling.amazonaws.com')), + managedPolicies: [ + iam.ManagedPolicy.fromAwsManagedPolicyName('GameLiftGameServerGroupPolicy'), + ], + }); + this.grantPrincipal = this.role; + + const resource = new CfnGameServerGroup(this, 'Resource', { + gameServerGroupName: this.physicalName, + autoScalingPolicy: this.parseAutoScalingPolicy(props), + deleteOption: props.deleteOption, + balancingStrategy: props.balancingStrategy, + gameServerProtectionPolicy: props.protectGameServer ? 'FULL_PROTECTION' : 'NO_PROTECTION', + instanceDefinitions: this.parseInstanceDefinitions(props), + launchTemplate: this.parseLaunchTemplate(props), + minSize: props.minSize, + maxSize: props.maxSize, + roleArn: this.role.roleArn, + vpcSubnets: subnetIds, + }); + + this.gameServerGroupName = this.getResourceNameAttribute(resource.ref); + this.gameServerGroupArn = this.getResourceArnAttribute(resource.attrGameServerGroupArn, { + service: 'gamelift', + resource: 'gameservergroup', + resourceName: this.physicalName, + arnFormat: cdk.ArnFormat.SLASH_RESOURCE_NAME, + }); + this.autoScalingGroupArn = this.getResourceArnAttribute(resource.attrAutoScalingGroupArn, { + service: 'autoscaling', + resource: 'autoScalingGroup', + resourceName: this.physicalName, + arnFormat: cdk.ArnFormat.COLON_RESOURCE_NAME, + }); + + } + + protected parseLaunchTemplate(props: GameServerGroupProps): CfnGameServerGroup.LaunchTemplateProperty { + return { + launchTemplateId: props.launchTemplate.launchTemplateId, + launchTemplateName: props.launchTemplate.launchTemplateName, + version: props.launchTemplate.versionNumber, + }; + } + + protected parseAutoScalingPolicy(props: GameServerGroupProps): CfnGameServerGroup.AutoScalingPolicyProperty | undefined { + if (!props.autoScalingPolicy) { + return undefined; + } + + return { + estimatedInstanceWarmup: props.autoScalingPolicy.estimatedInstanceWarmup?.toSeconds(), + targetTrackingConfiguration: { + targetValue: props.autoScalingPolicy.targetTrackingConfiguration, + }, + }; + } + + protected parseInstanceDefinitions(props: GameServerGroupProps): CfnGameServerGroup.InstanceDefinitionProperty[] { + return props.instanceDefinitions.map(parseInstanceDefinition); + + function parseInstanceDefinition(instanceDefinition: InstanceDefinition): CfnGameServerGroup.InstanceDefinitionProperty { + return { + instanceType: instanceDefinition.instanceType.toString(), + weightedCapacity: instanceDefinition.weight?.toString(), + }; + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/lib/index.ts b/packages/@aws-cdk/aws-gamelift/lib/index.ts index 13cc0c8eada9c..c71edfbfe2f08 100644 --- a/packages/@aws-cdk/aws-gamelift/lib/index.ts +++ b/packages/@aws-cdk/aws-gamelift/lib/index.ts @@ -1,6 +1,7 @@ export * from './content'; export * from './build'; export * from './script'; +export * from './game-server-group'; // AWS::GameLift CloudFormation Resources: export * from './gamelift.generated'; diff --git a/packages/@aws-cdk/aws-gamelift/package.json b/packages/@aws-cdk/aws-gamelift/package.json index 1096537b3c54e..877984f3fdddc 100644 --- a/packages/@aws-cdk/aws-gamelift/package.json +++ b/packages/@aws-cdk/aws-gamelift/package.json @@ -82,6 +82,7 @@ "devDependencies": { "@aws-cdk/assertions": "0.0.0", "@aws-cdk/cdk-build-tools": "0.0.0", + "@aws-cdk/integ-tests": "0.0.0", "@aws-cdk/integ-runner": "0.0.0", "@aws-cdk/integ-tests": "0.0.0", "@aws-cdk/cfn2ts": "0.0.0", diff --git a/packages/@aws-cdk/aws-gamelift/rosetta/default.ts-fixture b/packages/@aws-cdk/aws-gamelift/rosetta/default.ts-fixture index 4a4c332becb50..a343bb1afbee4 100644 --- a/packages/@aws-cdk/aws-gamelift/rosetta/default.ts-fixture +++ b/packages/@aws-cdk/aws-gamelift/rosetta/default.ts-fixture @@ -3,7 +3,8 @@ import { Construct } from 'constructs'; import { Duration, Size, Stack } from '@aws-cdk/core'; import * as gamelift from '@aws-cdk/aws-gamelift'; import * as s3 from '@aws-cdk/aws-s3'; -import * as kms from '@aws-cdk/aws-kms'; +import * as ec2 from '@aws-cdk/aws-ec2'; +import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; import * as iam from '@aws-cdk/aws-iam'; import * as path from 'path'; diff --git a/packages/@aws-cdk/aws-gamelift/test/game-server-group.test.ts b/packages/@aws-cdk/aws-gamelift/test/game-server-group.test.ts new file mode 100644 index 0000000000000..624bb3f7a350c --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/test/game-server-group.test.ts @@ -0,0 +1,342 @@ + +import { Template, Match } from '@aws-cdk/assertions'; +import * as ec2 from '@aws-cdk/aws-ec2'; +import * as iam from '@aws-cdk/aws-iam'; +import * as cdk from '@aws-cdk/core'; +import * as gamelift from '../lib'; + +describe('gameservergroup', () => { + describe('new', () => { + let stack: cdk.Stack; + let vpc: ec2.Vpc; + let launchTemplate: ec2.LaunchTemplate; + + beforeEach(() => { + stack = new cdk.Stack(); + vpc = new ec2.Vpc(stack, 'vpc'); + launchTemplate = new ec2.LaunchTemplate(stack, 'LaunchTemplte', {}); + }); + + test('default gameservergroup', () => { + + new gamelift.GameServerGroup(stack, 'MyGameServerGroup', { + instanceDefinitions: [{ + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE), + }], + vpc: vpc, + launchTemplate: launchTemplate, + gameServerGroupName: 'test-gameservergroup-name', + }); + + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Role', { + AssumeRolePolicyDocument: + { + Statement: + [{ + Action: 'sts:AssumeRole', + Effect: 'Allow', + Principal: { + Service: 'gamelift.amazonaws.com', + }, + }, + { + Action: 'sts:AssumeRole', + Effect: 'Allow', + Principal: { + Service: 'autoscaling.amazonaws.com', + }, + }], + Version: '2012-10-17', + }, + ManagedPolicyArns: [{ + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + ':iam::aws:policy/GameLiftGameServerGroupPolicy', + ], + ], + }], + }); + + Template.fromStack(stack).hasResource('AWS::GameLift::GameServerGroup', { + Properties: + { + GameServerGroupName: 'test-gameservergroup-name', + GameServerProtectionPolicy: 'NO_PROTECTION', + InstanceDefinitions: [{ InstanceType: 'c5.large' }], + LaunchTemplate: { + LaunchTemplateId: { Ref: 'LaunchTemplte29591DF8' }, + Version: { + 'Fn::GetAtt': [ + 'LaunchTemplte29591DF8', + 'LatestVersionNumber', + ], + }, + }, + RoleArn: { + 'Fn::GetAtt': [ + 'MyGameServerGroupServiceRoleD6701F0B', + 'Arn', + ], + }, + VpcSubnets: [ + { Ref: 'vpcPublicSubnet1Subnet2E65531E' }, + { Ref: 'vpcPublicSubnet2Subnet009B674F' }, + ], + }, + }); + }); + + test('with autoScalingPolicy', () => { + new gamelift.GameServerGroup(stack, 'MyGameServerGroup', { + instanceDefinitions: [{ + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE), + }], + vpc: vpc, + launchTemplate: launchTemplate, + gameServerGroupName: 'test-gameservergroup-name', + autoScalingPolicy: { + targetTrackingConfiguration: 10, + estimatedInstanceWarmup: cdk.Duration.minutes(5), + }, + }); + + Template.fromStack(stack).hasResource('AWS::GameLift::GameServerGroup', { + Properties: + { + GameServerGroupName: 'test-gameservergroup-name', + GameServerProtectionPolicy: 'NO_PROTECTION', + InstanceDefinitions: [{ InstanceType: 'c5.large' }], + LaunchTemplate: { + LaunchTemplateId: { Ref: 'LaunchTemplte29591DF8' }, + Version: { + 'Fn::GetAtt': [ + 'LaunchTemplte29591DF8', + 'LatestVersionNumber', + ], + }, + }, + RoleArn: { + 'Fn::GetAtt': [ + 'MyGameServerGroupServiceRoleD6701F0B', + 'Arn', + ], + }, + VpcSubnets: [ + { Ref: 'vpcPublicSubnet1Subnet2E65531E' }, + { Ref: 'vpcPublicSubnet2Subnet009B674F' }, + ], + AutoScalingPolicy: { + EstimatedInstanceWarmup: 300, + TargetTrackingConfiguration: { + TargetValue: 10, + }, + }, + }, + }); + }); + + test('with an incorrect game server group name length', () => { + let incorrectName = ''; + for (let i = 0; i < 129; i++) { + incorrectName += 'A'; + } + expect(() => new gamelift.GameServerGroup(stack, 'MyGameServerGroup', { + instanceDefinitions: [{ + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE), + }], + vpc: vpc, + launchTemplate: launchTemplate, + gameServerGroupName: incorrectName, + })).toThrow(/GameServerGroup name can not be longer than 128 characters but has 129 characters./); + }); + + test('with an incorrect game server group name format', () => { + let incorrectName = 'test with space'; + expect(() => new gamelift.GameServerGroup(stack, 'MyGameServerGroup', { + instanceDefinitions: [{ + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE), + }], + vpc: vpc, + launchTemplate: launchTemplate, + gameServerGroupName: incorrectName, + })).toThrow(/Game server group name test with space can contain only letters, numbers, hyphens, back slash or dot with no spaces./); + }); + + test('with an incorrect instance definitions list from constructor', () => { + let incorrectInstanceDefinitions: gamelift.InstanceDefinition[] = []; + for (let i = 0; i < 21; i++) { + incorrectInstanceDefinitions.push({ + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE), + }); + } + expect(() => new gamelift.GameServerGroup(stack, 'MyGameServerGroup', { + instanceDefinitions: incorrectInstanceDefinitions, + vpc: vpc, + launchTemplate: launchTemplate, + gameServerGroupName: 'test-name', + })).toThrow(/No more than 20 instance definitions are allowed per game server group, given 21/); + }); + + test('with incorrect minSize', () => { + expect(() => new gamelift.GameServerGroup(stack, 'MyGameServerGroup', { + instanceDefinitions: [{ + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE), + }], + vpc: vpc, + launchTemplate: launchTemplate, + gameServerGroupName: 'test-name', + minSize: -1, + })).toThrow(/The minimum number of instances allowed in the Amazon EC2 Auto Scaling group cannot be lower than 0, given -1/); + }); + + test('with incorrect maxSize', () => { + expect(() => new gamelift.GameServerGroup(stack, 'MyGameServerGroup', { + instanceDefinitions: [{ + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE), + }], + vpc: vpc, + launchTemplate: launchTemplate, + gameServerGroupName: 'test-name', + maxSize: -1, + })).toThrow(/The maximum number of instances allowed in the Amazon EC2 Auto Scaling group cannot be lower than 1, given -1/); + }); + }); + + describe('test import methods', () => { + let stack: cdk.Stack; + const gameServerGroupName = 'test-gameservergroup-name'; + const gameServerGroupArn = `arn:aws:gamelift:test-region:123456789012:gameservergroup/${gameServerGroupName}`; + const autoScalingGroupArn = 'arn:aws:autoscaling:test-region:123456789012:autoScalingGroup:test-uuid:autoScalingGroupName/test-name'; + + beforeEach(() => { + const app = new cdk.App(); + stack = new cdk.Stack(app, 'Base', { + env: { account: '111111111111', region: 'stack-region' }, + }); + }); + + test('with required attrs only', () => { + const importedFleet = gamelift.GameServerGroup.fromGameServerGroupAttributes(stack, 'ImportedScript', { gameServerGroupArn, autoScalingGroupArn }); + + expect(importedFleet.autoScalingGroupArn).toEqual(autoScalingGroupArn); + expect(importedFleet.gameServerGroupArn).toEqual(gameServerGroupArn); + expect(importedFleet.gameServerGroupName).toEqual(gameServerGroupName); + expect(importedFleet.env.account).toEqual('123456789012'); + expect(importedFleet.env.region).toEqual('test-region'); + expect(importedFleet.grantPrincipal).toEqual(new iam.UnknownPrincipal({ resource: importedFleet })); + }); + + test('with all attrs', () => { + const role = iam.Role.fromRoleArn(stack, 'Role', 'arn:aws:iam::123456789012:role/TestRole'); + const importedFleet = gamelift.GameServerGroup.fromGameServerGroupAttributes(stack, 'ImportedScript', { gameServerGroupArn, autoScalingGroupArn, role }); + + expect(importedFleet.autoScalingGroupArn).toEqual(autoScalingGroupArn); + expect(importedFleet.gameServerGroupArn).toEqual(gameServerGroupArn); + expect(importedFleet.gameServerGroupName).toEqual(gameServerGroupName); + expect(importedFleet.grantPrincipal).toEqual(role); + }); + + test('with missing attrs', () => { + const role = iam.Role.fromRoleArn(stack, 'Role', 'arn:aws:iam::123456789012:role/TestRole'); + expect(() => gamelift.GameServerGroup.fromGameServerGroupAttributes(stack, 'ImportedScript', { role, autoScalingGroupArn })) + .toThrow(/Either gameServerGroupName or gameServerGroupArn must be provided in GameServerGroupAttributes/); + }); + + test('with invalid ARN', () => { + expect(() => gamelift.GameServerGroup.fromGameServerGroupAttributes(stack, 'ImportedScript', { autoScalingGroupArn, gameServerGroupArn: 'arn:aws:gamelift:test-region:123456789012:gameservergroup' })) + .toThrow(/No game server group name found in ARN: 'arn:aws:gamelift:test-region:123456789012:gameservergroup'/); + }); + + test("the gameServerGroup's region is taken from the ARN", () => { + const importedFleet = gamelift.GameServerGroup.fromGameServerGroupAttributes(stack, 'ImportedScript', { gameServerGroupArn, autoScalingGroupArn }); + expect(importedFleet.env.region).toBe('test-region'); + }); + + test("the gameServerGroup's account is taken from the ARN", () => { + const importedFleet = gamelift.GameServerGroup.fromGameServerGroupAttributes(stack, 'ImportedScript', { gameServerGroupArn, autoScalingGroupArn }); + expect(importedFleet.env.account).toBe('123456789012'); + }); + }); + + describe('metric methods provide a Metric with configured and attached properties', () => { + let stack: cdk.Stack; + let vpc: ec2.Vpc; + let launchTemplate: ec2.LaunchTemplate; + let gameServerGroup: gamelift.GameServerGroup; + + beforeEach(() => { + stack = new cdk.Stack(undefined, undefined, { env: { account: '000000000000', region: 'us-west-1' } }); + vpc = new ec2.Vpc(stack, 'vpc'); + launchTemplate = new ec2.LaunchTemplate(stack, 'LaunchTemplte', {}); + gameServerGroup = new gamelift.GameServerGroup(stack, 'MyGameServerGroup', { + instanceDefinitions: [{ + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE), + }], + vpc: vpc, + launchTemplate: launchTemplate, + gameServerGroupName: 'test-gameservergroup-name', + }); + }); + + test('metric', () => { + const metric = gameServerGroup.metric('AvailableGameServers'); + + expect(metric).toMatchObject({ + account: stack.account, + region: stack.region, + namespace: 'AWS/GameLift', + metricName: 'AvailableGameServers', + dimensions: { + GameServerGroupArn: gameServerGroup.gameServerGroupArn, + }, + }); + }); + }); + + describe('granting access', () => { + let stack: cdk.Stack; + let vpc: ec2.Vpc; + let launchTemplate: ec2.LaunchTemplate; + let gameServerGroup: gamelift.GameServerGroup; + let role: iam.Role; + + beforeEach(() => { + stack = new cdk.Stack(undefined, undefined, { env: { account: '000000000000', region: 'us-west-1' } }); + vpc = new ec2.Vpc(stack, 'vpc'); + role = new iam.Role(stack, 'Role', { + assumedBy: new iam.ServicePrincipal('gamelift.amazonaws.com'), + }); + launchTemplate = new ec2.LaunchTemplate(stack, 'LaunchTemplte', {}); + gameServerGroup = new gamelift.GameServerGroup(stack, 'MyGameServerGroup', { + instanceDefinitions: [{ + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE), + }], + vpc: vpc, + launchTemplate: launchTemplate, + gameServerGroupName: 'test-gameservergroup-name', + role: role, + }); + }); + + test('grant', () => { + gameServerGroup.grant(role, 'gamelift:DescribeGameServerGroup'); + + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { + PolicyDocument: { + Statement: [ + Match.objectLike({ + Action: 'gamelift:DescribeGameServerGroup', + Resource: stack.resolve(gameServerGroup.gameServerGroupArn), + }), + ], + }, + Roles: [stack.resolve(role.roleName)], + }); + }); + }); +}); \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/GameServerGroupDefaultTestDeployAssertA631B19B.assets.json b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/GameServerGroupDefaultTestDeployAssertA631B19B.assets.json new file mode 100644 index 0000000000000..f7fa24e781380 --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/GameServerGroupDefaultTestDeployAssertA631B19B.assets.json @@ -0,0 +1,19 @@ +{ + "version": "21.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "GameServerGroupDefaultTestDeployAssertA631B19B.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/GameServerGroupDefaultTestDeployAssertA631B19B.template.json b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/GameServerGroupDefaultTestDeployAssertA631B19B.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/GameServerGroupDefaultTestDeployAssertA631B19B.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/aws-gamelift-game-server-group.assets.json b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/aws-gamelift-game-server-group.assets.json new file mode 100644 index 0000000000000..5d2d42f94c1eb --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/aws-gamelift-game-server-group.assets.json @@ -0,0 +1,19 @@ +{ + "version": "21.0.0", + "files": { + "0233f946355da9a29bd7caaf5049caf4cd4e71dfa10d084bd5ff56e547903847": { + "source": { + "path": "aws-gamelift-game-server-group.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "0233f946355da9a29bd7caaf5049caf4cd4e71dfa10d084bd5ff56e547903847.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/aws-gamelift-game-server-group.template.json b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/aws-gamelift-game-server-group.template.json new file mode 100644 index 0000000000000..451002608b0dc --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/aws-gamelift-game-server-group.template.json @@ -0,0 +1,551 @@ +{ + "Resources": { + "Vpc8378EB38": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": [ + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/Vpc" + } + ] + } + }, + "VpcPublicSubnet1Subnet5C2D37C4": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.0.0/18", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/Vpc/PublicSubnet1" + } + ] + } + }, + "VpcPublicSubnet1RouteTable6C95E38E": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/Vpc/PublicSubnet1" + } + ] + } + }, + "VpcPublicSubnet1RouteTableAssociation97140677": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + } + } + }, + "VpcPublicSubnet1DefaultRoute3DA9E72A": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ] + }, + "VpcPublicSubnet1EIPD7E02669": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/Vpc/PublicSubnet1" + } + ] + } + }, + "VpcPublicSubnet1NATGateway4D7517AA": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "SubnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + "AllocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet1EIPD7E02669", + "AllocationId" + ] + }, + "Tags": [ + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/Vpc/PublicSubnet1" + } + ] + }, + "DependsOn": [ + "VpcPublicSubnet1DefaultRoute3DA9E72A", + "VpcPublicSubnet1RouteTableAssociation97140677" + ] + }, + "VpcPublicSubnet2Subnet691E08A3": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.64.0/18", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/Vpc/PublicSubnet2" + } + ] + } + }, + "VpcPublicSubnet2RouteTable94F7E489": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/Vpc/PublicSubnet2" + } + ] + } + }, + "VpcPublicSubnet2RouteTableAssociationDD5762D8": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + } + }, + "VpcPublicSubnet2DefaultRoute97F91067": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ] + }, + "VpcPublicSubnet2EIP3C605A87": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/Vpc/PublicSubnet2" + } + ] + } + }, + "VpcPublicSubnet2NATGateway9182C01D": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "SubnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + }, + "AllocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet2EIP3C605A87", + "AllocationId" + ] + }, + "Tags": [ + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/Vpc/PublicSubnet2" + } + ] + }, + "DependsOn": [ + "VpcPublicSubnet2DefaultRoute97F91067", + "VpcPublicSubnet2RouteTableAssociationDD5762D8" + ] + }, + "VpcPrivateSubnet1Subnet536B997A": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.128.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/Vpc/PrivateSubnet1" + } + ] + } + }, + "VpcPrivateSubnet1RouteTableB2C5B500": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/Vpc/PrivateSubnet1" + } + ] + } + }, + "VpcPrivateSubnet1RouteTableAssociation70C59FA6": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "SubnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + } + } + }, + "VpcPrivateSubnet1DefaultRouteBE02A9ED": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VpcPublicSubnet1NATGateway4D7517AA" + } + } + }, + "VpcPrivateSubnet2Subnet3788AAA1": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.192.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/Vpc/PrivateSubnet2" + } + ] + } + }, + "VpcPrivateSubnet2RouteTableA678073B": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/Vpc/PrivateSubnet2" + } + ] + } + }, + "VpcPrivateSubnet2RouteTableAssociationA89CAD56": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "SubnetId": { + "Ref": "VpcPrivateSubnet2Subnet3788AAA1" + } + } + }, + "VpcPrivateSubnet2DefaultRoute060D2087": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VpcPublicSubnet2NATGateway9182C01D" + } + } + }, + "VpcIGWD7BA715C": { + "Type": "AWS::EC2::InternetGateway", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/Vpc" + } + ] + } + }, + "VpcVPCGWBF912B6E": { + "Type": "AWS::EC2::VPCGatewayAttachment", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "InternetGatewayId": { + "Ref": "VpcIGWD7BA715C" + } + } + }, + "LaunchTemplate04EC5460": { + "Type": "AWS::EC2::LaunchTemplate", + "Properties": { + "LaunchTemplateData": { + "ImageId": { + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" + }, + "TagSpecifications": [ + { + "ResourceType": "instance", + "Tags": [ + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/LaunchTemplate" + } + ] + }, + { + "ResourceType": "volume", + "Tags": [ + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/LaunchTemplate" + } + ] + } + ] + }, + "TagSpecifications": [ + { + "ResourceType": "launch-template", + "Tags": [ + { + "Key": "Name", + "Value": "aws-gamelift-game-server-group/LaunchTemplate" + } + ] + } + ] + } + }, + "MyGameServerGroupServiceRoleD6701F0B": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": [ + "autoscaling.amazonaws.com", + "gamelift.amazonaws.com" + ] + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/GameLiftGameServerGroupPolicy" + ] + ] + } + ] + } + }, + "MyGameServerGroupA706FA3E": { + "Type": "AWS::GameLift::GameServerGroup", + "Properties": { + "GameServerGroupName": "test-gameservergroup-name", + "InstanceDefinitions": [ + { + "InstanceType": "c5.large" + }, + { + "InstanceType": "c4.large" + } + ], + "LaunchTemplate": { + "LaunchTemplateId": { + "Ref": "LaunchTemplate04EC5460" + }, + "Version": { + "Fn::GetAtt": [ + "LaunchTemplate04EC5460", + "LatestVersionNumber" + ] + } + }, + "RoleArn": { + "Fn::GetAtt": [ + "MyGameServerGroupServiceRoleD6701F0B", + "Arn" + ] + }, + "BalancingStrategy": "ON_DEMAND_ONLY", + "GameServerProtectionPolicy": "FULL_PROTECTION", + "MaxSize": 10, + "MinSize": 1, + "VpcSubnets": [ + { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + ] + } + } + }, + "Parameters": { + "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2" + }, + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/cdk.out b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/cdk.out new file mode 100644 index 0000000000000..8ecc185e9dbee --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"21.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/integ.json b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/integ.json new file mode 100644 index 0000000000000..7dfb7ecf345df --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "21.0.0", + "testCases": { + "GameServerGroup/DefaultTest": { + "stacks": [ + "aws-gamelift-game-server-group" + ], + "assertionStack": "GameServerGroup/DefaultTest/DeployAssert", + "assertionStackName": "GameServerGroupDefaultTestDeployAssertA631B19B" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/manifest.json b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/manifest.json new file mode 100644 index 0000000000000..97bde0478466e --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/manifest.json @@ -0,0 +1,267 @@ +{ + "version": "21.0.0", + "artifacts": { + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + }, + "aws-gamelift-game-server-group.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "aws-gamelift-game-server-group.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "aws-gamelift-game-server-group": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "aws-gamelift-game-server-group.template.json", + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/0233f946355da9a29bd7caaf5049caf4cd4e71dfa10d084bd5ff56e547903847.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "aws-gamelift-game-server-group.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "aws-gamelift-game-server-group.assets" + ], + "metadata": { + "/aws-gamelift-game-server-group/Vpc/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Vpc8378EB38" + } + ], + "/aws-gamelift-game-server-group/Vpc/PublicSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1Subnet5C2D37C4" + } + ], + "/aws-gamelift-game-server-group/Vpc/PublicSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1RouteTable6C95E38E" + } + ], + "/aws-gamelift-game-server-group/Vpc/PublicSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1RouteTableAssociation97140677" + } + ], + "/aws-gamelift-game-server-group/Vpc/PublicSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1DefaultRoute3DA9E72A" + } + ], + "/aws-gamelift-game-server-group/Vpc/PublicSubnet1/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1EIPD7E02669" + } + ], + "/aws-gamelift-game-server-group/Vpc/PublicSubnet1/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1NATGateway4D7517AA" + } + ], + "/aws-gamelift-game-server-group/Vpc/PublicSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2Subnet691E08A3" + } + ], + "/aws-gamelift-game-server-group/Vpc/PublicSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2RouteTable94F7E489" + } + ], + "/aws-gamelift-game-server-group/Vpc/PublicSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2RouteTableAssociationDD5762D8" + } + ], + "/aws-gamelift-game-server-group/Vpc/PublicSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2DefaultRoute97F91067" + } + ], + "/aws-gamelift-game-server-group/Vpc/PublicSubnet2/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2EIP3C605A87" + } + ], + "/aws-gamelift-game-server-group/Vpc/PublicSubnet2/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2NATGateway9182C01D" + } + ], + "/aws-gamelift-game-server-group/Vpc/PrivateSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1Subnet536B997A" + } + ], + "/aws-gamelift-game-server-group/Vpc/PrivateSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1RouteTableB2C5B500" + } + ], + "/aws-gamelift-game-server-group/Vpc/PrivateSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1RouteTableAssociation70C59FA6" + } + ], + "/aws-gamelift-game-server-group/Vpc/PrivateSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1DefaultRouteBE02A9ED" + } + ], + "/aws-gamelift-game-server-group/Vpc/PrivateSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2Subnet3788AAA1" + } + ], + "/aws-gamelift-game-server-group/Vpc/PrivateSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2RouteTableA678073B" + } + ], + "/aws-gamelift-game-server-group/Vpc/PrivateSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2RouteTableAssociationA89CAD56" + } + ], + "/aws-gamelift-game-server-group/Vpc/PrivateSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2DefaultRoute060D2087" + } + ], + "/aws-gamelift-game-server-group/Vpc/IGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcIGWD7BA715C" + } + ], + "/aws-gamelift-game-server-group/Vpc/VPCGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcVPCGWBF912B6E" + } + ], + "/aws-gamelift-game-server-group/LaunchTemplate/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "LaunchTemplate04EC5460" + } + ], + "/aws-gamelift-game-server-group/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": [ + { + "type": "aws:cdk:logicalId", + "data": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" + } + ], + "/aws-gamelift-game-server-group/MyGameServerGroup/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyGameServerGroupServiceRoleD6701F0B" + } + ], + "/aws-gamelift-game-server-group/MyGameServerGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyGameServerGroupA706FA3E" + } + ], + "/aws-gamelift-game-server-group/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-gamelift-game-server-group/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "aws-gamelift-game-server-group" + }, + "GameServerGroupDefaultTestDeployAssertA631B19B.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "GameServerGroupDefaultTestDeployAssertA631B19B.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "GameServerGroupDefaultTestDeployAssertA631B19B": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "GameServerGroupDefaultTestDeployAssertA631B19B.template.json", + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "GameServerGroupDefaultTestDeployAssertA631B19B.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "GameServerGroupDefaultTestDeployAssertA631B19B.assets" + ], + "metadata": { + "/GameServerGroup/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/GameServerGroup/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "GameServerGroup/DefaultTest/DeployAssert" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/tree.json b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/tree.json new file mode 100644 index 0000000000000..486d29aa67194 --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.js.snapshot/tree.json @@ -0,0 +1,898 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.140" + } + }, + "aws-gamelift-game-server-group": { + "id": "aws-gamelift-game-server-group", + "path": "aws-gamelift-game-server-group", + "children": { + "Vpc": { + "id": "Vpc", + "path": "aws-gamelift-game-server-group/Vpc", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-gamelift-game-server-group/Vpc/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPC", + "aws:cdk:cloudformation:props": { + "cidrBlock": "10.0.0.0/16", + "enableDnsHostnames": true, + "enableDnsSupport": true, + "instanceTenancy": "default", + "tags": [ + { + "key": "Name", + "value": "aws-gamelift-game-server-group/Vpc" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnVPC", + "version": "0.0.0" + } + }, + "PublicSubnet1": { + "id": "PublicSubnet1", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.0.0/18", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "aws-gamelift-game-server-group/Vpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet1/Acl", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "tags": [ + { + "key": "Name", + "value": "aws-gamelift-game-server-group/Vpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "subnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VpcIGWD7BA715C" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet1/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "aws-gamelift-game-server-group/Vpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet1/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "subnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + "allocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet1EIPD7E02669", + "AllocationId" + ] + }, + "tags": [ + { + "key": "Name", + "value": "aws-gamelift-game-server-group/Vpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PublicSubnet2": { + "id": "PublicSubnet2", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "availabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.64.0/18", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "aws-gamelift-game-server-group/Vpc/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet2/Acl", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "tags": [ + { + "key": "Name", + "value": "aws-gamelift-game-server-group/Vpc/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "subnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VpcIGWD7BA715C" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet2/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "aws-gamelift-game-server-group/Vpc/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "aws-gamelift-game-server-group/Vpc/PublicSubnet2/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "subnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + }, + "allocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet2EIP3C605A87", + "AllocationId" + ] + }, + "tags": [ + { + "key": "Name", + "value": "aws-gamelift-game-server-group/Vpc/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet1": { + "id": "PrivateSubnet1", + "path": "aws-gamelift-game-server-group/Vpc/PrivateSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "aws-gamelift-game-server-group/Vpc/PrivateSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.128.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "aws-gamelift-game-server-group/Vpc/PrivateSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "aws-gamelift-game-server-group/Vpc/PrivateSubnet1/Acl", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "aws-gamelift-game-server-group/Vpc/PrivateSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "tags": [ + { + "key": "Name", + "value": "aws-gamelift-game-server-group/Vpc/PrivateSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "aws-gamelift-game-server-group/Vpc/PrivateSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "subnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "aws-gamelift-game-server-group/Vpc/PrivateSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VpcPublicSubnet1NATGateway4D7517AA" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet2": { + "id": "PrivateSubnet2", + "path": "aws-gamelift-game-server-group/Vpc/PrivateSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "aws-gamelift-game-server-group/Vpc/PrivateSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "availabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.192.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "aws-gamelift-game-server-group/Vpc/PrivateSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "aws-gamelift-game-server-group/Vpc/PrivateSubnet2/Acl", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "aws-gamelift-game-server-group/Vpc/PrivateSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "tags": [ + { + "key": "Name", + "value": "aws-gamelift-game-server-group/Vpc/PrivateSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "aws-gamelift-game-server-group/Vpc/PrivateSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "subnetId": { + "Ref": "VpcPrivateSubnet2Subnet3788AAA1" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "aws-gamelift-game-server-group/Vpc/PrivateSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VpcPublicSubnet2NATGateway9182C01D" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "IGW": { + "id": "IGW", + "path": "aws-gamelift-game-server-group/Vpc/IGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::InternetGateway", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "aws-gamelift-game-server-group/Vpc" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnInternetGateway", + "version": "0.0.0" + } + }, + "VPCGW": { + "id": "VPCGW", + "path": "aws-gamelift-game-server-group/Vpc/VPCGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPCGatewayAttachment", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "internetGatewayId": { + "Ref": "VpcIGWD7BA715C" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnVPCGatewayAttachment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.Vpc", + "version": "0.0.0" + } + }, + "LaunchTemplate": { + "id": "LaunchTemplate", + "path": "aws-gamelift-game-server-group/LaunchTemplate", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-gamelift-game-server-group/LaunchTemplate/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::LaunchTemplate", + "aws:cdk:cloudformation:props": { + "launchTemplateData": { + "imageId": { + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" + }, + "tagSpecifications": [ + { + "resourceType": "instance", + "tags": [ + { + "key": "Name", + "value": "aws-gamelift-game-server-group/LaunchTemplate" + } + ] + }, + { + "resourceType": "volume", + "tags": [ + { + "key": "Name", + "value": "aws-gamelift-game-server-group/LaunchTemplate" + } + ] + } + ] + }, + "tagSpecifications": [ + { + "resourceType": "launch-template", + "tags": [ + { + "key": "Name", + "value": "aws-gamelift-game-server-group/LaunchTemplate" + } + ] + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnLaunchTemplate", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.LaunchTemplate", + "version": "0.0.0" + } + }, + "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": { + "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", + "path": "aws-gamelift-game-server-group/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118": { + "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118", + "path": "aws-gamelift-game-server-group/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "MyGameServerGroup": { + "id": "MyGameServerGroup", + "path": "aws-gamelift-game-server-group/MyGameServerGroup", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "aws-gamelift-game-server-group/MyGameServerGroup/ServiceRole", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-gamelift-game-server-group/MyGameServerGroup/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": [ + "autoscaling.amazonaws.com", + "gamelift.amazonaws.com" + ] + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/GameLiftGameServerGroupPolicy" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-gamelift-game-server-group/MyGameServerGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::GameLift::GameServerGroup", + "aws:cdk:cloudformation:props": { + "gameServerGroupName": "test-gameservergroup-name", + "instanceDefinitions": [ + { + "instanceType": "c5.large" + }, + { + "instanceType": "c4.large" + } + ], + "launchTemplate": { + "launchTemplateId": { + "Ref": "LaunchTemplate04EC5460" + }, + "version": { + "Fn::GetAtt": [ + "LaunchTemplate04EC5460", + "LatestVersionNumber" + ] + } + }, + "roleArn": { + "Fn::GetAtt": [ + "MyGameServerGroupServiceRoleD6701F0B", + "Arn" + ] + }, + "balancingStrategy": "ON_DEMAND_ONLY", + "gameServerProtectionPolicy": "FULL_PROTECTION", + "maxSize": 10, + "minSize": 1, + "vpcSubnets": [ + { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-gamelift.CfnGameServerGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-gamelift.GameServerGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + }, + "GameServerGroup": { + "id": "GameServerGroup", + "path": "GameServerGroup", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "GameServerGroup/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "GameServerGroup/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.140" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "GameServerGroup/DefaultTest/DeployAssert", + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.IntegTest", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.ts b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.ts new file mode 100644 index 0000000000000..5a44e66394d92 --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/test/integ.game-server-group.ts @@ -0,0 +1,45 @@ +import * as ec2 from '@aws-cdk/aws-ec2'; +import * as cdk from '@aws-cdk/core'; +import { IntegTest } from '@aws-cdk/integ-tests'; +import { Construct } from 'constructs'; +import * as gamelift from '../lib'; +import { BalancingStrategy } from '../lib'; + +class TestStack extends cdk.Stack { + constructor(scope: Construct, id: string, props?: cdk.StackProps) { + super(scope, id, props); + + // Create default VPC + const vpc = new ec2.Vpc(this, 'Vpc'); + + //Create default launch template + const launchTemplate = new ec2.LaunchTemplate(this, 'LaunchTemplate', { + machineImage: ec2.MachineImage.latestAmazonLinux(), + }); + + new gamelift.GameServerGroup(this, 'MyGameServerGroup', { + instanceDefinitions: [{ + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE), + }, + { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE), + }], + minSize: 1, + maxSize: 10, + protectGameServer: true, + balancingStrategy: BalancingStrategy.ON_DEMAND_ONLY, + vpc: vpc, + launchTemplate: launchTemplate, + gameServerGroupName: 'test-gameservergroup-name', + }); + } +} + +// Beginning of the test suite +const app = new cdk.App(); +const stack = new TestStack(app, 'aws-gamelift-game-server-group'); +new IntegTest(app, 'GameServerGroup', { + testCases: [stack], +}); + +app.synth(); \ No newline at end of file