Gems/AWSGameLift/cdk/aws_gamelift/gamelift_stack.py [78:136]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def _create_fleet(self, fleet_configuration: dict, identifier: int) -> gamelift.CfnFleet:
        """
        Create an Amazon GameLift fleet to host game servers.
        :param fleet_configuration: Configuration of the fleet.
        :param identifier: Unique identifier of the fleet which will be included in the resource id.
        :return: Generated GameLift fleet.
        """
        fleet = gamelift.CfnFleet(
            self,
            id=f'{self._stack_name}-GameLiftFleet{identifier}',
            build_id=self._get_gamelift_build_id(fleet_configuration.get('build_configuration', {}), identifier),
            certificate_configuration=gamelift.CfnFleet.CertificateConfigurationProperty(
                certificate_type=fleet_configuration['certificate_configuration'].get('certificate_type')
            ) if fleet_configuration.get('certificate_configuration') else None,
            description=fleet_configuration.get('description'),
            ec2_inbound_permissions=[
                gamelift.CfnFleet.IpPermissionProperty(
                    **inbound_permission
                ) for inbound_permission in fleet_configuration.get('ec2_inbound_permissions', [])
            ],
            ec2_instance_type=fleet_configuration.get('ec2_instance_type'),
            fleet_type=fleet_configuration.get('fleet_type'),
            name=f'{self._stack_name}-GameLiftFleet{identifier}',
            new_game_session_protection_policy=fleet_configuration.get('new_game_session_protection_policy'),
            resource_creation_limit_policy=gamelift.CfnFleet.ResourceCreationLimitPolicyProperty(
                **fleet_configuration['resource_creation_limit_policy']
            ) if fleet_configuration.get('resource_creation_limit_policy') else None,
            runtime_configuration=gamelift.CfnFleet.RuntimeConfigurationProperty(
                game_session_activation_timeout_seconds=fleet_configuration['runtime_configuration'].get(
                    'game_session_activation_timeout_seconds'),
                max_concurrent_game_session_activations=fleet_configuration['runtime_configuration'].get(
                    'max_concurrent_game_session_activations'),
                server_processes=[
                    gamelift.CfnFleet.ServerProcessProperty(
                        **server_process
                    ) for server_process in fleet_configuration['runtime_configuration'].get('server_processes', [])
                ]
            ) if fleet_configuration.get('runtime_configuration') else None,
        )

        return fleet

    def _get_gamelift_build_id(self, build_configuration: dict, identifier: int) -> str:
        """
        Create a GameLift build using the storage location if the build doesn't exist and return the build id.
        :param build_configuration: Configuration of the GameLift build.
        :param identifier: Unique identifier of the build which will be included in the resource id.
        :return: Build id.
        """
        if build_configuration.get('build_id'):
            # GameLift build already exists
            return build_configuration['build_id']
        elif build_configuration.get('storage_location'):
            # Create the GameLift build using the storage location information.
            build = gamelift.CfnBuild(
                self,
                id=f'{self._stack_name}-GameLiftBuild{identifier}',
                name=f'{self._stack_name}-GameLiftBuild{identifier}',
                operating_system=build_configuration.get('operating_system'),
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



Gems/AWSGameLift/cdkv1/aws_gamelift/gamelift_stack.py [74:132]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def _create_fleet(self, fleet_configuration: dict, identifier: int) -> gamelift.CfnFleet:
        """
        Create an Amazon GameLift fleet to host game servers.
        :param fleet_configuration: Configuration of the fleet.
        :param identifier: Unique identifier of the fleet which will be included in the resource id.
        :return: Generated GameLift fleet.
        """
        fleet = gamelift.CfnFleet(
            self,
            id=f'{self._stack_name}-GameLiftFleet{identifier}',
            build_id=self._get_gamelift_build_id(fleet_configuration.get('build_configuration', {}), identifier),
            certificate_configuration=gamelift.CfnFleet.CertificateConfigurationProperty(
                certificate_type=fleet_configuration['certificate_configuration'].get('certificate_type')
            ) if fleet_configuration.get('certificate_configuration') else None,
            description=fleet_configuration.get('description'),
            ec2_inbound_permissions=[
                gamelift.CfnFleet.IpPermissionProperty(
                    **inbound_permission
                ) for inbound_permission in fleet_configuration.get('ec2_inbound_permissions', [])
            ],
            ec2_instance_type=fleet_configuration.get('ec2_instance_type'),
            fleet_type=fleet_configuration.get('fleet_type'),
            name=f'{self._stack_name}-GameLiftFleet{identifier}',
            new_game_session_protection_policy=fleet_configuration.get('new_game_session_protection_policy'),
            resource_creation_limit_policy=gamelift.CfnFleet.ResourceCreationLimitPolicyProperty(
                **fleet_configuration['resource_creation_limit_policy']
            ) if fleet_configuration.get('resource_creation_limit_policy') else None,
            runtime_configuration=gamelift.CfnFleet.RuntimeConfigurationProperty(
                game_session_activation_timeout_seconds=fleet_configuration['runtime_configuration'].get(
                    'game_session_activation_timeout_seconds'),
                max_concurrent_game_session_activations=fleet_configuration['runtime_configuration'].get(
                    'max_concurrent_game_session_activations'),
                server_processes=[
                    gamelift.CfnFleet.ServerProcessProperty(
                        **server_process
                    ) for server_process in fleet_configuration['runtime_configuration'].get('server_processes', [])
                ]
            ) if fleet_configuration.get('runtime_configuration') else None,
        )

        return fleet

    def _get_gamelift_build_id(self, build_configuration: dict, identifier: int) -> str:
        """
        Create a GameLift build using the storage location if the build doesn't exist and return the build id.
        :param build_configuration: Configuration of the GameLift build.
        :param identifier: Unique identifier of the build which will be included in the resource id.
        :return: Build id.
        """
        if build_configuration.get('build_id'):
            # GameLift build already exists
            return build_configuration['build_id']
        elif build_configuration.get('storage_location'):
            # Create the GameLift build using the storage location information.
            build = gamelift.CfnBuild(
                self,
                id=f'{self._stack_name}-GameLiftBuild{identifier}',
                name=f'{self._stack_name}-GameLiftBuild{identifier}',
                operating_system=build_configuration.get('operating_system'),
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



