Compare commits

...

10 Commits

Author SHA1 Message Date
hamilcarBarca17
99c4336627 Updated readme to include troubleshooting steps 2023-05-02 16:03:05 -06:00
hamilcarBarca17
1013a6a9b2 Piped unnecessary backend command into /dev/null so it's not displayed in the UI 2023-04-11 12:29:43 -06:00
hamilcarBarca17
2dd371bc0b Fixed a bug in updating the instance IP on new instance startup 2023-04-11 12:14:55 -06:00
hamilcarBarca17
765522cb4a Changed full screen prompt default to yes 2023-03-08 17:26:14 -07:00
hamilcarBarca17
1b6084c0fd Fixed steam client install on the EC2 instance 2023-03-08 16:48:50 -07:00
hamilcarBarca17
952732d0b6 Corrected the Nice DCV installer 2023-03-08 16:33:02 -07:00
hamilcarBarca17
f29bb1129d Added step to install CDK if it's not already installed 2023-03-08 16:09:41 -07:00
hamilcarBarca17
36f64dd1f8 Fixed a typo in the key for fetching the instance password 2023-03-08 16:04:02 -07:00
hamilcarBarca17
a7838ce8d0 Updated README 2023-03-08 15:45:05 -07:00
hamilcarBarca17
a06e201c93 Require the user to specify the AZ for the subnet 2023-03-08 15:33:07 -07:00
7 changed files with 42 additions and 25 deletions
+18 -7
View File
@@ -20,15 +20,20 @@ This repo will automate the creation and connection to an AWS EC2 spot instance
### CDK Variables
Modify the following properties in the [cloud-gaming-on-ec2](cdk/bin/cloud-gaming-on-ec2.ts) stack:
| Parameter Name | Description |
|----------------|---------------------------------------------------------------------|
| `ACCOUNT_ID` | The AWS account ID you want to use |
| `REGION` | The AWS region in which you want the resources created |
| `VPC_ID` | The ID of the VPC you wish to deploy the instance into |
| `SUBNET_ID` | The ID of a public subnet that you want your instance deployed into |
| Parameter Name | Description |
|----------------------------|---------------------------------------------------------------------|
| `ACCOUNT_ID` | The AWS account ID you want to use |
| `REGION` | The AWS region in which you want the resources created |
| `VPC_ID` | The ID of the VPC you wish to deploy the instance into |
| `SUBNET_ID` | The ID of a public subnet that you want your instance deployed into |
| `SUBNET_AVAILABILITY_ZONE` | The availability zone of the subnet you provided |
## Running the application
To run the application, simply run the `cloud-gaming.sh` script in the root directory and follow all instructions/menu choices and the script will take care of everything else!
To run the application, simply run
```shell
./cloud-gaming.sh
```
from the root directory and follow all instructions/menu choices and the script will take care of everything else!
## Debugging
The scripts output logs to `/tmp/cloud-gaming.log` for easy debugging and auditing.
@@ -82,6 +87,12 @@ The `Stream Settings` menu in the `cloud-gaming.sh` script will guide you throug
Note: A Shared stream will not overwrite your settings to connect to your personal instance. You'll just have to change back to your personal instance in Steam Link via the Gear icon -> Computers menu.
## Troubleshooting
> I can't connect to my instance again after rebooting
Your public IP may have changed, so you may be blocked from the security group. To correct it, simply re-deploy the stack and skip the setup steps again.
This will update the security group with your current public IP address and allow you access to the instance again.
## Built With
* [Bash](https://www.gnu.org/software/bash/) - Shell that all the scripts are written in
* [Node.js](https://nodejs.org/en/) - JS runtime for CDK
+4 -9
View File
@@ -56,7 +56,7 @@ waitForInstanceToBecomeAvailable() {
declare increment
increment=$(echo "scale=1; 100/90" | bc)
for ((i=0; i<=100; i=$(printf "%.0f" $(echo "scale=1; $i + $increment" | bc)))); do
if (timeout 10s nc -vz "$AWS_TEAM_BUILDING_EC2_INSTANCE_IP" 8443); then
if (timeout 10s nc -vz "$AWS_TEAM_BUILDING_EC2_INSTANCE_IP" 8443 2>&1 > /dev/null); then
break
fi
echo "$i"
@@ -73,7 +73,7 @@ getInstanceIp() {
createDcvConnectionProfileFromTemplate() {
printInfo "Creating DCV connection profile from template"
PASSWORD="$(aws --profile $AWS_CLOUD_GAMING_PROFILE ec2 get-password-data --instance-id "$AWS_TEAM_BUILDING_EC2_INSTANCE_ID" --priv-launch-key ~/.ssh/insights-team-building-key-pair.pem --query 'PasswordData' --output text --no-cli-auto-prompt)"
PASSWORD="$(aws --profile $AWS_CLOUD_GAMING_PROFILE ec2 get-password-data --instance-id "$AWS_TEAM_BUILDING_EC2_INSTANCE_ID" --priv-launch-key ~/.ssh/"$AWS_CLOUD_GAMING_SSH_KEY".pem --query 'PasswordData' --output text --no-cli-auto-prompt)"
PASSWORD=$(echo -n $PASSWORD)
sed -i "/^host=/c\host=$AWS_TEAM_BUILDING_EC2_INSTANCE_IP" cloud_gaming_dcv_profile.dcv
sed -i "/^password=/c\password=$PASSWORD" cloud_gaming_dcv_profile.dcv
@@ -94,8 +94,9 @@ startInstance() {
showGaugeBoxForAwsCommand "$desiredState" "Starting Your Instance" "Successfully Started Your Instance!" "Failed to start your instance!"
printInfo "Checking to see if IP changed"
instanceIp=$(getInstanceIp)
if [[ $instanceIp != $AWS_TEAM_BUILDING_EC2_INSTANCE_IP ]]; then
if [[ $instanceIp != "$AWS_TEAM_BUILDING_EC2_INSTANCE_IP" ]]; then
setConfigValue "AWS_TEAM_BUILDING_EC2_INSTANCE_IP" "$instanceIp"
export AWS_TEAM_BUILDING_EC2_INSTANCE_IP="$instanceIp"
createDcvConnectionProfileFromTemplate
fi
@@ -166,12 +167,6 @@ deployCdk() {
} | whiptail --title "Preparing CDK..." --gauge "Preparing CDK..." "$GAUGE_BOX_HEIGHT" "$GAUGE_BOX_WIDTH" 0
declare pid
declare synthLogFile="${logFile}-synth.log"
printInfo "Running CDK synth and logging to $synthLogFile"
yes | npx cdk --no-color --require-approval never --profile $AWS_CLOUD_GAMING_PROFILE -c "user=$user" -c "localIp=$localIp" synth "TeamBuildingCloudGaming-$user" > $synthLogFile 2>&1 &
pid=$!
showTailBox "Synthesizing CDK" $pid $synthLogFile
declare bootstrapLogFile="${logFile}-bootstrap.log"
printInfo "Bootstrapping CDK and logging to $bootstrapLogFile"
yes | npx cdk --no-color --require-approval never --profile $AWS_CLOUD_GAMING_PROFILE -c "user=$user" -c "localIp=$localIp" bootstrap > $bootstrapLogFile 2>&1 &
+3 -1
View File
@@ -14,6 +14,7 @@ const ACCOUNT_ID = "PLACEHOLDER"
const REGION = "us-east-1"
const VPC_ID = 'PLACEHOLDER'
const SUBNET_ID = 'PLACEHOLDER'
const SUBNET_AVAILABILITY_ZONE = 'PLACEHOLDER'
const user = app.node.tryGetContext("user");
if (!user) {
@@ -47,5 +48,6 @@ new G4ADStack(app, `TeamBuildingCloudGaming-${user}`, {
},
user,
vpcId: VPC_ID,
subnetId: SUBNET_ID
subnetId: SUBNET_ID,
subnetAvailabilityZone: SUBNET_AVAILABILITY_ZONE
});
+3 -2
View File
@@ -22,6 +22,7 @@ export interface BaseConfig extends StackProps {
readonly instanceSize: InstanceSize;
readonly vpcId: string;
readonly subnetId: string;
readonly subnetAvailabilityZone: string;
readonly sshKeyName: string;
readonly volumeSizeGiB: number;
readonly niceDCVDisplayDriverUrl: string;
@@ -37,7 +38,7 @@ export abstract class BaseEc2Stack extends Stack {
constructor(scope: App, id: string, props: BaseConfig) {
super(scope, id, props);
this.props = props;
const { vpcId, subnetId, sshKeyName, volumeSizeGiB, openPorts, allowInboundCidr, user } = props;
const { vpcId, subnetId, subnetAvailabilityZone, sshKeyName, volumeSizeGiB, openPorts, allowInboundCidr, user } = props;
const vpc = Vpc.fromLookup(this, "Vpc", { vpcId });
const securityGroup = new SecurityGroup(this, `SecurityGroup-${user}`, {
@@ -82,7 +83,7 @@ export abstract class BaseEc2Stack extends Stack {
instanceType: this.getInstanceType(),
vpc,
securityGroup,
vpcSubnets: vpc.selectSubnets({ subnets: [Subnet.fromSubnetAttributes(this, 'publicSubnet', {subnetId, availabilityZone: "us-east-1a"})] }),
vpcSubnets: vpc.selectSubnets({ subnets: [Subnet.fromSubnetAttributes(this, 'publicSubnet', {subnetId, availabilityZone: subnetAvailabilityZone})] }),
keyName: sshKeyName,
userData: this.getUserdata(),
machineImage: MachineImage.latestWindows(WindowsVersion.WINDOWS_SERVER_2019_ENGLISH_FULL_BASE),
+1 -1
View File
@@ -42,7 +42,7 @@ export class G4ADStack extends BaseEc2Stack {
'Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(\'https://community.chocolatey.org/install.ps1\'))',
'choco feature enable -n=allowGlobalConfirmation',
'choco install steam-rom-manager',
'choco install steam-client',
'choco install steam-client --ignore-checksums',
'choco install microsoft-edge',
`Start-Process msiexec.exe -Wait -ArgumentList '/I C:\\Users\\Administrator\\Desktop\\InstallationFiles\\2_NICEDCV-Server.msi /QN /L* "C:\\msilog.log"'`,
`Start-Process msiexec.exe -Wait -ArgumentList '/I C:\\Users\\Administrator\\Desktop\\InstallationFiles\\3_NICEDCV-DisplayDriver.msi /QN /L* "C:\\msilog.log"'`,
+8 -3
View File
@@ -41,7 +41,7 @@ createPrerequisitesMap() {
put $mapName "dialog" $linuxName
put $mapName "pulsemixer" $linuxName
put $mapName "nc" $linuxName
put $mapName "mas" $darwinName
put $mapName "python" $darwinName
put $mapName "pulseaudio" $darwinName
@@ -96,7 +96,7 @@ verifyPrerequisites() {
printWarn "Installing the FlatHub repo for Flatpak if it doesn't already exist..."
echo "$SUDO_PASSWORD" | sudo -k -S flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
printWarn "Installing SteamLink from FlatHub..."
echo "$SUDO_PASSWORD" | sudo -k -S flatpak install flathub com.valvesoftware.SteamLink
echo "$SUDO_PASSWORD" | sudo -k -S flatpak install -y flathub com.valvesoftware.SteamLink
fi
# elif [[ $KERNEL == "Darwin" ]]; then
# TODO check if SteamLink is installed, and if not, install it via mas-cli
@@ -117,6 +117,11 @@ verifyPrerequisites() {
exit 1
fi
if ! (hash cdk 2> /dev/null); then
printWarn "CDK is not installed. Installing now..." true
echo "$SUDO_PASSWORD" | sudo -k -S npm -g install aws-cdk@latest
fi
checkAwsProfile
}
@@ -320,7 +325,7 @@ deployInstance() {
if (whiptail --fb --title "Setup" --yesno "We'll now go through the first time setup. Do you wish to continue?" "$BOX_HEIGHT" "$BOX_WIDTH"); then
msgBox "For first time setups, ensure your terminal is full screen so you don't miss any instructions. If it's not, exit this application, enter full screen, then start again"
if (whiptail --fb --title "First Time Setup" --yesno "This will now perform first time setup for your cloud gaming instance. Is your terminal full screen?" --defaultno "$BOX_HEIGHT" "$BOX_WIDTH"); then
if (whiptail --fb --title "First Time Setup" --yesno "This will now perform first time setup for your cloud gaming instance. Is your terminal full screen?" "$BOX_HEIGHT" "$BOX_WIDTH"); then
printInfo "Running first time setup"
msgBox "For the first run, some manual, one-time setup steps are required. When ready, hit 'OK' to continue and start the connection to your instance's desktop."
+5 -2
View File
@@ -17,8 +17,10 @@ prepareStream() {
echo -e "XXX\n0\nInstalling NICE DCV Client... \nXXX"
printInfo "Installing NICE DCV Viewer client"
# if [[ $kernel == "Linux" ]]; then
wget -o nice-dcv-viewer.deb https://d1uj6qtbmh3dt5.cloudfront.net/2022.1/Clients/nice-dcv-viewer_2022.1.4251-1_amd64.ubuntu2004.deb > /dev/null 2>&1
echo "$SUDO_PASSWORD" | sudo -k -S sh -c "dpkg -i nice-dcv-viewer.deb" > /dev/null 2>&1
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1-1ubuntu2.1~18.04.21_amd64.deb > /dev/null 2>&1
echo "$SUDO_PASSWORD" | sudo -k -S sh -c "dpkg -i libssl1.1_1.1.1-1ubuntu2.1~18.04.21_amd64.deb" > /dev/null 2>&1
wget https://d1uj6qtbmh3dt5.cloudfront.net/2022.1/Clients/nice-dcv-viewer_2022.1.4251-1_amd64.ubuntu2004.deb > /dev/null 2>&1
echo "$SUDO_PASSWORD" | sudo -k -S sh -c "dpkg -i nice-dcv-viewer_2022.1.4251-1_amd64.ubuntu2004.deb" > /dev/null 2>&1
# elif [[ $kernel == "Darwin" ]]; then
# if [[ $architecture == "x86_64" ]]; then
# wget -o nice-dcv-viewer.dmg https://d1uj6qtbmh3dt5.cloudfront.net/2022.1/Clients/nice-dcv-viewer-2022.1.4279.x86_64.dmg > /dev/null 2>&1
@@ -32,6 +34,7 @@ prepareStream() {
echo -e "XXX\n33\nCleaning up... \nXXX"
printInfo "Removing downloaded DCV Viewer installation"
rm nice-dcv-viewer* > /dev/null 2>&1
rm libssl1* > /dev/null 2>&1
echo -e "XXX\n66\nCreating Connection Profile from template... \nXXX"
createDcvConnectionProfileFromTemplate
echo -e "XXX\n100\nDone! \nXXX"