diff --git a/README.md b/README.md index c66eadc..88f7e6a 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,13 @@ 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! diff --git a/aws-tools.sh b/aws-tools.sh index 4e5c0fd..8d67155 100644 --- a/aws-tools.sh +++ b/aws-tools.sh @@ -166,12 +166,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 & diff --git a/cdk/bin/cloud-gaming-on-ec2.ts b/cdk/bin/cloud-gaming-on-ec2.ts index 5618103..f12aacf 100644 --- a/cdk/bin/cloud-gaming-on-ec2.ts +++ b/cdk/bin/cloud-gaming-on-ec2.ts @@ -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 }); diff --git a/cdk/lib/base.ts b/cdk/lib/base.ts index 4526bd7..5bc38af 100644 --- a/cdk/lib/base.ts +++ b/cdk/lib/base.ts @@ -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), diff --git a/cloud-gaming.sh b/cloud-gaming.sh index 8eb6150..99389cf 100755 --- a/cloud-gaming.sh +++ b/cloud-gaming.sh @@ -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