Coder Social home page Coder Social logo

badjware / aws-cloud-gaming Goto Github PK

View Code? Open in Web Editor NEW
84.0 5.0 32.0 45 KB

Terraform module to automate the provisioning an AWS EC2 instance with a gpu to play games in the cloud using Parsec.

License: Other

PowerShell 6.97% HCL 47.81% Smarty 45.22%
cloud gaming aws-ec2 parsec streaming terraform

aws-cloud-gaming's Introduction

aws-cloud-gaming

Provision an AWS EC2 instance with a gpu to play games in the cloud. Uses terraform to create the required infrastructure and a user data script to install the applications on the instance. Once configured, games can be streamed from the instance with low-latency using Parsec.

The scripts in this repository automate most of the manual operations needed to setup such an instance. The only exception is management of AMIs, which must be done through the AWS management console.

Currently only compatible with g3 and g4 instance family. The script will still run on other instance types, but gpu driver will have to be installed manually.

These scripts create resources in AWS and your credit card WILL be charged for them. Be sure to review changes before applying them. These scripts come with no warranty of any kind, use them at your own risk.

Features

Infrastructure

  • No fiddling with key pairs. A random Administrator password is saved in SSM, set on boot, and retrievable with terraform.
  • Restrictive security group. Allow ingress to RDP (port 3389) and VNC (port 5900) only from the computer that created the instance.
  • Use a spot instance for around 50% to 70% cost saving compared to an on-demand instance.
  • Use the latest Windows Server 2019 AMI available in the region by default, and allow the use of a custom AMI after the inital setup.

Instance provisioning

Optionally, other launcher than Steam such as GOG Galaxy, Uplay, etc. can be downloaded and installed automatically.

Getting started

See the in-depth guide.

tl;dr:

# Assuming terraform, powershell, curl, and aws credentials are installed

# Set the desired region and create the infra 
echo 'region = "us-east-1"' >terraform.tfvars
terraform init
terraform apply

# Get the instance ip
terraform output instance_ip

# Get the Administrator password
terraform output instance_password

(Advanced) Using as a terraform module

This repository can be used as a terraform module. One use-case would be to attach an extra volume to the instance to store games.

locals {
    region = "us-east-1"
    availability_zone_identifier = "a"
    availability_zone = "${local.region}${local.availability_zone_identifier}"
}

provider "aws" {
  region = local.region
}

module "cloud_gaming" {
    source = "github.com/badjware/aws-cloud-gaming"

    region = local.region
    # The instance and the volume must be on the same AZ
    allowed_availability_zone_identifier = [local.availability_zone_identifier]
    # We won't need much space on our root block device
    root_block_device_size_gb = 40
}

resource "aws_ebs_volume" "games_volume" {
    availability_zone = local.availability_zone
    size = 200
}

resource "aws_volume_attachment" "game_volume_attachment" {
    device_name = "/dev/sdb"
    volume_id   = aws_ebs_volume.games_volume.id
    instance_id = module.cloud_gaming.instance_id
}

Inputs

Name Description Type Default
region The aws region. Choose the one closest to you: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions string
allowed_availability_zone_identifier The allowed availability zone identify (the letter suffixing the region). Choose ones that allows you to request the desired instance as spot instance in your region. An availability zone will be selected at random and the instance will be booted in it. list(string) ["a", "b"]
instance_type The aws instance type, Choose one with a CPU/GPU that fits your need: https://aws.amazon.com/ec2/instance-types/#Accelerated_Computing string "g4dn.xlarge"
resource_name Name with which to prefix resources in AWS string cloud-gaming
root_block_device_size_gb The size of the root block device (C:\ drive) attached to the instance number 120
custom_ami Use the specified ami instead of the most recent windows ami in available in the region string ""
skip_install Skip installation step on startup. Useful when using a custom AMI that is already setup bool false
install_parsec Download and run Parsec-Cloud-Preparation-Tool on first login bool true
install_auto_login Configure auto-login on first boot bool true
install_graphic_card_driver Download and install the Nvidia driver on first boot bool true
install_steam Download and install Valve Steam on first boot bool true
install_gog_galaxy Download and install GOG Galaxy on first boot bool false
install_uplay Download and install Ubisoft Uplay on first boot bool false
install_origin Download and install EA Origin on first boot bool false
install_epic_games_launcher Download and install EPIC Games Launcher on first boot bool false

Outputs

Name Description Type
instance_id The id of the instance string
instance_ip The ip address of the instance. Use it to connect string
instance_public_dns The dns address of the instance. Use it to connect string
instance_password The Administrator password of the instance. Use it to connect string

aws-cloud-gaming's People

Contributors

badjware avatar marcel-g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aws-cloud-gaming's Issues

Licensed driver is an executable, not zip

The code block to download the licensed Nvidia driver:

# vGaming driver for g4
$Bucket = "nvidia-gaming"
$KeyPrefix = "windows/latest"
# download and extract driver
$Objects = Get-S3Object -BucketName $Bucket -KeyPrefix $KeyPrefix -Region us-east-1
foreach ($Object in $Objects) {
if ($Object.Size -ne 0) {
$LocalFileName = "C:\nvidia-driver\driver.zip"
Copy-S3Object -BucketName $Bucket -Key $Object.Key -LocalFile $LocalFileName -Region us-east-1
Expand-Archive $LocalFileName -DestinationPath $ExtractionPath
break
}
}

Assumes that the file in the S3 bucket is a zip file. It's not. It's an executable that unzips.

This logic ought to inspect the file(s) found when listing the Bucket contents, rather than assuming the file type.

This project's owner seems to have lost interest; their last activity was on 2020-06-30; this issue proposes a fork to continue the project

@KetchupBomb, yours seems to be the the most developed fork since then (in terms of number of commits and most recently updated, see https://useful-forks.github.io/?repo=badjware/aws-cloud-gaming). This issue could serve as the primary discoverability mechanism. Are you interested in maintaining your fork for other users? If so, consider responding positively here and opening up the issues section on your fork.

Parsec logs out on reboot

Looks like the TeamMachineSetup scheduled task causes your Parsec account to get logged out on every reboot. This happens because it checks if the instance has any user data configured and if so, attempts to auto-login to a Parsec teams account. Because your guide uses instance user data for auto-configuration, this behavior is triggered (and since no teams configuration is present, it attempts to log in with an invalid account).

Disabling the scheduled task fixes this issue for me (but there is probably a better way too).

Hard-coded AZ zone identifiers not appropriate for all regions

Northern California (us-west-1) doesn't have an "a" Availability Zone identifier:

$ aws ec2 describe-availability-zones | jq -r .AvailabilityZones[].ZoneName
us-west-1b
us-west-1c

This can cause an error when the module randomly picks "a" from the default list of ["a", "b"].

Assignees:
Labels:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.