├── LICENSE
├── README.md
├── SnapAndDelete.py
├── images
├── 2019Base.png
├── SecurityGroup.png
├── awsconfigure.png
├── createfunction.png
├── createkeys.png
├── decrypted.png
├── doom.png
├── ec2access.png
├── event1.png
├── functionrole.png
├── functiontimeout.png
├── g4dnxlarge.png
├── instance_started.png
├── launchid1.png
├── launchid2.png
├── launchtags.png
├── pastedfunction.png
├── prepcopy.png
├── ps1.png
├── ps2.png
├── ps3.png
├── ps5.png
├── ps6.png
├── ps7.png
├── pserror.png
├── region.png
├── running_instances.png
├── serverok.png
├── spot.png
├── spoterror.png
├── storage.png
├── tagginginstance.png
├── testsuccess.png
├── tutorial1.png
├── tutorial2.png
├── tutorial3.png
├── tutorial4.png
├── tutorial5.png
├── tutorial6.png
├── tutorial7.png
└── tutorial8.png
├── start_server.ps1
└── start_server.sh
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020-2021 Keith Vassallo
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Parsec AWS Automation Scripts & Guide
2 | =====================================
3 |
4 | | Info | Value |
5 | | ------------- |:-------------|
6 | | Created by | Keith Vassallo |
7 | | Acknowledgements | [/u/rom-ok](https://www.reddit.com/user/rom-ok)
[/u/dolanders](https://www.reddit.com/user/dolanders)
[@Cookie-Monster-Coder](https://github.com/Cookie-Monster-Coder)
[@rhigueras](https://github.com/rhigueras)
[@srichter](https://github.com/srichter)
The [Parsec Team](https://parsecgaming.com/) |
8 | | Related Reading | [Parsec AWS Guide](https://blog.parsecgaming.com/rtx-cloud-gaming-with-the-new-aws-g4-instances-11d1c60c2d09) |
9 |
10 | Check out a video version of this guide at: https://www.youtube.com/watch?v=gE20QLY6gAI
11 |
12 | ## Table of Contents
13 |
14 | **[Aims](#aims)**
15 | **[Setting up the Server](#setting-up-the-server)**
16 | **[Installing Parsec](#installing-parsec)**
17 | **[Creating the Automation Script](#creating-the-automation-script)**
18 | **[Creating the Start Script](#creating-the-start-script)**
19 | **[Putting it All Together](#putting-it-all-together)**
20 |
21 | ## Aims
22 |
23 | The aims of this guide are as follows:
24 |
25 | * Roll your own cloud gaming server.
26 | * Be able to install any game you want, regardless of which store it's available on, and even if it's not in any store.
27 | * Do it as cheaply as possible.
28 | * Automate it such that when you're done gaming, you just need to shutdown the server.
29 |
30 | ## Setting up the Server
31 |
32 | We'll begin by following the Parsec AWS guide.
33 |
34 | 1. If you haven't already, create a [Parsec Account](https://parsecgaming.com/signup/) and download the [Parsec Client](https://parsecgaming.com/downloads)
35 | 2. If you haven't already, create an [AWS Account]().
36 | 3. Optionally, create a [Razer Account](https://aws.amazon.com/registration-confirmation/).
37 | 4. Download Microsoft Remote Desktop Client [for Windows](https://www.microsoft.com/en-us/p/microsoft-remote-desktop/9wzdncrfj3ps?activetab=pivot:overviewtab) or [for macOS](https://docs.microsoft.com/en-us/windows-server/remote/remote-desktop-services/clients/remote-desktop-mac) or something like [Remmina](https://flathub.org/apps/details/org.remmina.Remmina) for Linux.
38 | 4. Login to the [AWS Console](https://console.aws.amazon.com) using your root account.
39 | 5. Go to **Services > EC2**.
40 | 6. Click on **Running Instances**.
41 |
42 | 
43 |
44 | 7. Choose a region closest to you (from the top right).
45 |
46 | 
47 |
48 | 8. Click **Launch Instance**. Select **Windows Server 2019 Base**.
49 |
50 | 
51 |
52 | 9. From the next screen, choose the **g4dn.xlarge** instance type.
53 |
54 | 
55 |
56 | 10. Click **Next: Configure Instance Details**.
57 |
58 | 11. Leave all options unchanged, and move on to **Next: Add Storage**. From here, you will need to choose how big you want your disk to be. I chose 512GB, since it's roomy and I typically don't leave all my games installed at once. Of course, you can choose any size you want here, but bear in mind you are charged per GB. Choose **General Purpose SSD (gp2)** as the storage type and make sure you turn **OFF** the **Delete on Termination** checkbox. This ensures our volume isn't destroyed when we shutdown our machine. We'll be creating a script to handle that part for us.
59 |
60 | 
61 |
62 | 12. Move on to **Next: Add Tags**. This is **Very Important** so don't skip it. You'll want to create a tag called **Name** - with a capital **N**. For the value, choose a name for your gaming server. Make sure that the checkboxes for both **Instances** and **Volumes** are checked.
63 |
64 | 
65 |
66 | 13. Move on to **Next: Configure Security Group**. Leave the default option to create a new security group, and give it an easy-to-remember name, such as **Your_Instance_Name_Here-Sg**.
67 |
68 | 
69 |
70 | 14. Now click **Review and Launch** and click **Launch**. You'll be asked to create a key pair. Click **Create a new key pair** and give the key a name.
71 |
72 | 
73 |
74 | 15. **Download** the key and keep it somewhere safe. I strongly recommend you create a folder on your system to keep all documents related to your gaming rig. From now on, I'll refer to this as **That Folder**.
75 |
76 | 16. Finally, click **Launch Instances**. Now, you'll get a message that your instance was launched successfully.
77 |
78 | 17. Our instance has launched! To confirm, click **View Instances** and then click **Instances**. You'll see the instance is starting or has already started.
79 |
80 | 
81 |
82 | 18. Now we'll connect to the instance. With your instance selected, click **Connect**, then switch to the **RDP client** tab, click **Download Remote Desktop File** and add it to **That Folder**. Next, click **Get Password**. If you get a warning about the password not being available yet, close the window and click **Connect** again after a few minutes. Browse to the location of your key file (it should be in **That Folder**). This will display the key contents in the window.
83 |
84 | 
85 |
86 | 29. Click **Decrypt Password**. You will be shown the username (**Administrator**) and your password. Save these somewhere safe, I suggest in **That Folder** at first, but eventually move these to a proper password manager.
87 |
88 | ## Installing Parsec
89 |
90 | We'll now install Parsec via their awesome script, which will also install other stuff to make our life easier, as well as update the GPU drivers.
91 |
92 | 1. Double-click on the RDP file you downloaded earlier, this will open a connection in Microsoft RDP Client, with the username already filled in. Simply paste the password and click **Connect**. You will connect to the desktop of the instance.
93 |
94 | 2. Now click **Start** and type **PowerShell**, click on **Windows PowerShell**. Now we need to get the Parsec setup script. Head on over to the [Parsec Cloud Preparation Tool GitHub](https://github.com/jamesstringerparsec/Parsec-Cloud-Preparation-Tool) and copy the script given:
95 |
96 | 
97 |
98 | 3. Now, back in your RDP session, paste the script in PowerShell. This will extract a compress file. Press **Enter** to continue the process.
99 |
100 | 
101 |
102 | 4. You will be asked whether to configure automatic Windows login. Type **Y** to accept this. You will be asked for your username and password, which you placed earlier in **That Folder**.
103 | 4.1. If this dialog did not work, you can turn on automatic logon in Windows by following instruction from this [page](https://learn.microsoft.com/en-us/troubleshoot/windows-server/user-profiles-and-logon/turn-on-automatic-logon)
104 |
105 | 
106 |
107 | 5. The script will now install a bunch of stuff, including DirectX 11, Chrome, Parsec and 7zip. Depending on the script version, AWS, Microsoft and the alignment of the moon, you may sometimes get errors from the script. These will probably show that one or more downloads failed, typically for Direct X and the XBox Game controller driver. If you do get this error, you can download Direct X from [here](https://community.pcgamingwiki.com/files/file/2106-legacy-directx-sdk-redist-directx_jun2010_redistexe/) and the XBox contoller driver from [here](https://www.techspot.com/drivers/driver/file/information/11300/).
108 |
109 | 5.1 If gamepad still doesn't work you may need to install driver manually by following [this instructions]
110 | (https://github.com/ViGEm/ViGEmBus/issues/153).
111 |
112 | 
113 |
114 | 6. When Parsec is installed, you'll see the Parsec client - go ahead and login. The login won't work at first, but you'll receive an e-mail asking you to confirm your location. Click on **Approve your new location** once you get the email, then login to Parsec on your gaming server.
115 |
116 | 7. Eventually you'll see a pop-up for Razer Synapse - asking you to login. You don't need to login - we just need this installed. Go ahead and close it. **Note: On Windows Server 2016 you may need to login and/or close the app for the script to continue.**.
117 |
118 | 
119 |
120 | 8. The Parsec script will now continue with the GPU updater tool. You'll be prompted to provide an Access Key and Secret. To do this, copy the link that is shown in the prompt, and paste it in your browser, or just [click here](https://console.aws.amazon.com/iam/home?/security_credentials#/security_credentials).
121 |
122 | 
123 |
124 | 9. Now click on **Access keys (access ID and secret access key)** and click **Create New Access Key**. Click **Download Key File** and add this to **That Folder**. Then click **Show Access Key** - this will show the access key and secret access key. Copy the first one and paste it in the PowerShell window, pressing **Enter**. Then copy the secret key and also paste it in PowerShell, followed by **Enter**. You'll be asked whether to save the access key - type **y**. Answer the next two questions with **y**.
125 |
126 | 
127 |
128 | - If this step fails, you may need to apply fix for GPUUpdaterTool.ps1 as suggested [here](https://github.com/parsec-cloud/Parsec-Cloud-Preparation-Tool/issues/93#issuecomment-1135741304)
129 |
130 | 10. When the driver is installed, you'll be advised whether or not you need to reboot.
131 |
132 | 11. If you rebooted, use the steps outlined in step 1 to re-connect to your system via RDP.
133 |
134 | 12. At this point you should configure Parsec (double-click the Parsec icon on your desktop). I used the following settings:
135 |
136 | - Host Settings
137 | - If you're on macOS, change **Resolution** to match the resolution of your personal system. You can find this out by clicking **Apple > About this Mac > Displays**. If you don't do this, connecting via Parsec will fail to change the resolution of the server to match your system. Windows/Linux users don't need to do this.
138 | - Increase the **Bandwidth Limit** to **50 Mbps**.
139 | - Give the host an easy to remember name.
140 | - Client Settings - not really required, but ¯\_(ツ)_/¯
141 | - Change **Resolution** to match your setting from above.
142 | - Set **H.265 (HEVC)** to **On**.
143 |
144 | 13. At this point, the Parsec client on your system should show the server as available.
145 |
146 | 
147 |
148 | 14. Optionally, double-click on the **Setup Auto Shutdown** icon on your desktop. This will shutdown your system after a number of minutes if its idle, just in case you forget to do it yourself. When prompted, I set it to 45 minutes.
149 |
150 | 15. Optionally, doublick-click on the **Setup One Hour Warning** icon on your desktop. This will warn you when you have been connected for an hour, so you can better manage your billing.
151 |
152 | 16. Now, disconnect from your server (i.e. close the RDP window), and connect to the server via Parsec instead. You're now ready to game! If you're not interested in the automation stuff, you can now skip to the [Gaming](#gaming) section.
153 |
154 | ## Creating the Automation Script
155 |
156 | This section is optional - however it might be something you look into. This basically configures the following:
157 |
158 | - When you're done gaming, you just shutdown the server.
159 | - The script is called automatically when the server is terminated. It:
160 | - Takes a snapshot of the volume.
161 | - Creates an AMI of from the snapshot.
162 | - Deletes the volume
163 | - Deletes old snapshots and AMIs.
164 |
165 | The reason we do this is because keeping a snapshot is cheaper than keeping a volume. We also have an AMI so we can easily re-launch the instance later and continue where we left off. I've also created a script to do this automatically, which is described in the next section.
166 |
167 | 1. Shutdown your rig (**Start > Shutdown**) then from the AWS console, go to **Services > Lambda**.
168 |
169 | 2. Click **Create Function** and give it a name. In my case I called it **SnapAndDelete** - but any name will do. For the **Runtime**, choose **Python 3.8**. Then click **Create Function**.
170 |
171 | 
172 |
173 | 3. You'll see a code editor where you can create your function. Grab the function code from [here](https://github.com/keithvassallomt/parsec-aws-automation/blob/master/SnapAndDelete.py), and paste it in the code editor.
174 |
175 | 
176 |
177 | 4. Now, you'll want to change the three variables.
178 |
179 | ```Python
180 | GAMING_INSTANCE_NAME = 'GamingRig' # Replace this with the name of your server
181 | GAMING_INSTANCE_REGION = 'eu-west-3' # Replace this with the region your server is in
182 | GAMING_INSTANCE_SIZE_GB = 512 # Replace this with the size of your disk
183 | ```
184 |
185 | 5. The function will typically only run for a few seconds, however there is an exception. Snapshots in AWS are built incrementally, which is why they're so fast - except the first time we create a snapshot there's nothing to base on, so the entire 512GB volume needs to be snapshotted, which takes a while. It will also take a while to take a snapshot after installing a large game. So, we'll increase our function execution time limit. Scroll down to **Basic Settings** and click **Edit**, then set the **Timeout** to 15 minutes. Click **Save** when you're done.
186 |
187 | 
188 |
189 | 6. Click **Deploy** to save the function. Next, we need to give our function permission to manage our EC2 resources. To do this, click on **Permissions** from the top, and click on the role that AWS automatically created for your function.
190 |
191 | 
192 |
193 | 7. Now click **Attach Policies**, search for **EC2** and choose the **AmazonEC2FullAccess** policy. Click **Attach Policy**
194 |
195 | 
196 |
197 | 8. At this point, you should **really** test that the function works. From the EC2 console, Terminate the instance (**Instance State > Terminate**). Then, back in Lambda, click **Test > Create Test Event** and give the event a name. Then click **Test** to see whether the function works. If it does, you should see output similar to the following (note that this will take a while):
198 |
199 | 
200 |
201 | 9. Next, we need to tell AWS to run this function every time our instance is terminated. Go to **Services > Amazon EventBridge**, then click **Create rule**. Fill in the form as follows:
202 |
203 | - **Name:** Any name.
204 | - **Description:** Any description.
205 | - **Define Pattern:** Event Pattern.
206 | - **Event matching pattern:** Pre-defined pattern by service.
207 | - **Service provider:** AWS.
208 | - **Service Name:** EC2.
209 | - **Event Type:** EC2 Instance State-change Notification.
210 | - **Specific state(s):** Checked, and choose **terminated** from the list of states.
211 |
212 | 9. Now from **Select targets**, and from the **Function** drop-down, choose the Lambda function we created earlier. Note that the function checks instance tags when doing its thing, so it won't mess around with your other instances/volumes/snapshots/AMIs.
213 |
214 | 
215 |
216 | 10. At this point, shutdown your gaming rig, then from the EC2 console choose **Actions > Terminate**. This will terminate the instance and the Lamda function should kick in, which will create the initial snapshot of the machine. You can monitor it from the **Snapshots** section of the EC2 console. Note that this initial snapshot will take a while to complete, but following this snapshots shouldn't take that long - it depends on how many changes you've made to the machine whilst using it.
217 |
218 | ## Creating the Start Script
219 |
220 | This section is also optional. Here we create a script that will automatically launch a gaming instance using spot pricing for us, without having to login to the AWS Console.
221 |
222 | 1. Go to **Services > EC2 > Launch Templates**. Click **Create Launch Template**.
223 |
224 | 2. Now, you need configure the template with the following settings:
225 |
226 | - **Launch template name:** Set any name here.
227 | - **Template version description:** 1
228 | - **AMI:** Don't include in launch template.
229 | - **Instance Type:** g4dn.xlarge (or whatever size you chose).
230 | - **Key pair (login):** Choose the key you created when creating the instance.
231 |
232 | 3. Under **Storage (volumes)** click **Add new volume** with the following settings:
233 |
234 | - **Size (GiB):** 512 (or whatever size you're using).
235 | - **Device name:** /dev/sda1 - you need to choose **Specify a custom value...** to be able to do this.
236 | - **Volume type:** General purpose SSD (gp2)
237 | - **Delete on termination:** No
238 | - **Encrypted:** No
239 |
240 | 4. Under **Resource tags**, click **Add Tag** and create a tag with the Key set to **Name** and the Value set to the name of your gaming server (**GamingRig** in my case). Make sure that both **Instances** and **Volumes** are selected under **Resource Types**. Now click **Add Tag** again, and create a tag with the Key set to **SnapAndDelete** and the Value set to **True** - again making sure that both **Tag instances** and **Tag volumes** are enabled. Note that tag keys and values are CASE SENSITIVE.
241 |
242 | 
243 |
244 | 5. Expand **Advanced details**, then:
245 |
246 | - **Request Spot Instances:** Checked.
247 | - Click **Customize** then click **Set your maximum price (per instance/hour)** and set your price to some value greater than the instance average. You can see current average prices [here](https://aws.amazon.com/ec2/spot/pricing/) - make sure you choose your region. For example, the average in eu-west-3 is $0.37, so I set it to $0.40.
248 | - **Shutdown behavior:** Terminate.
249 | - **Termination protection:** Disable.
250 | - **Detailed CloudWatch monitoring:** Disable.
251 |
252 | 6. Phew! Finally, we can click **Create launch template**, followed by **View launch template**.
253 |
254 | 7. Now, you need to get the start script for your system. If you're using macOS or Linux, you need [start_server.sh](https://github.com/keithvassallomt/parsec-aws-automation/blob/master/start_server.sh). If you're using Windows, you need [start_server.ps1](https://github.com/keithvassallomt/parsec-aws-automation/blob/master/start_server.ps1). Add this script to **That Folder**.
255 |
256 | 8. Open the file you downloaded, and change the following if on Linux/macOS:
257 |
258 | ```Bash
259 | GAMING_INSTANCE_NAME = "GamingRig" # Replace this with the name of your server
260 | LAUNCH_TEMPLATE = "lt-123434abcd" # Replace this with the launch template ID
261 | ```
262 |
263 | Or the following if on Windows:
264 |
265 | ```powershell
266 | $GAMING_INSTANCE_NAME = "GamingRig" # Replace this with the name of your server
267 | $LAUNCH_TEMPLATE = "lt-123434abcd" # Replace this with the launch template ID
268 | ```
269 |
270 | To get your launch template ID easily, click on the launch template ID from the AWS Console:
271 |
272 | 
273 |
274 | Now click the copy icon next to the launch template ID.
275 |
276 | 
277 |
278 | 9. If you're using Linux or macOS, you need to make the file executable. To do this, open a terminal (on macOS just search for **Terminal** from Spotlight or Applications > Utilities, on Linux - you should know how to do that already). Then, type:
279 |
280 | ```bash
281 | cd /path/to/ThatFolder
282 | chmod +x start_script.sh
283 | ```
284 |
285 | Obviously replace the **/path/to/** part with the path to **That Folder**.
286 |
287 | 10. For the start script to work, you need to have the AWS CLI installed. If not, you can can install it on Windows from [Here](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html), or macOS from [Here](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html) or Linux from [Here](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html).
288 |
289 | 11. If you've just installed the AWS CLI you then need to configure it. Open a terminal on Linux or macOS, or open Command Prompt or PowerShell on Windows. Then type **aws configure**. You will be asked questions, answer as follows:
290 |
291 | - **AWS Access Key ID:** The access key you used in step 9 of the **Installing Parsec** section.
292 | - **AWS Secret Access Key:** The secret key from the same step. Note that you should have stored these in **That Folder**.
293 | - **Default region name:** The region where you set up your gaming server.
294 | - **Default output format:** json.
295 |
296 | 
297 |
298 | ## Putting it All Together
299 |
300 | We're done! We can now take our server out for a spin, which will also let me explain exactly how to use this thing.
301 |
302 | 1. OK, so you're in the mood to kill some demons. The first thing you do is open a terminal on Linux/macOS or PowerShell on Windows. You then run the start script using **./start_script.sh** on Linux/macOS, or **start_script.ps1** on Windows.
303 |
304 | 
305 |
306 | 2. When the instance is run, you will be shown the instance details. Press **q** to hide these.
307 |
308 | 
309 |
310 | 3. At this point, open the Parsec client and just wait for your server to boot up. Following this you can connect to your server and game away.
311 |
312 | 
313 |
314 | 4. Once you're done gaming, all you need to do is shutdown the server.
315 |
316 | 
317 |
318 | 5. At this point, you can go ahead with your life. However, since this is the first time, let's use the AWS Console to see what's happening behind the scenes. After shutting down your server, from **Services > EC2 > Instances** we can see our instance is shutting down. After a short while it will change to the Terminated state.
319 |
320 | 
321 |
322 | 6. If you go to **Snapshots**, you'll see that our script starts creating a snapshot.
323 |
324 | 
325 |
326 | 7. After the snapshot is ready, going to the **Volumes** section shows that the volume has been deleted.
327 |
328 | 
329 |
330 | 8. In the **Images** section, you'll see the brand new AMI, ready for your next gaming session.
331 |
332 | 
333 |
334 | ## Gaming
335 | I installed Steam and Doom Eternal to gave it a shot.
336 |
337 | 
338 |
--------------------------------------------------------------------------------
/SnapAndDelete.py:
--------------------------------------------------------------------------------
1 | import boto3
2 | import botocore
3 |
4 | GAMING_INSTANCE_NAME = 'YOUR GAMING RIG NAME GOES HERE'
5 | GAMING_INSTANCE_REGION = 'eu-west-3'
6 | GAMING_INSTANCE_SIZE_GB = 512
7 |
8 |
9 | def lambda_handler(object, context):
10 | ec2 = boto3.client('ec2')
11 |
12 | # Connect to region
13 | ec2 = boto3.client('ec2',region_name=GAMING_INSTANCE_REGION)
14 | res_client = boto3.resource('ec2', region_name=GAMING_INSTANCE_REGION)
15 |
16 | # Get all available volumes
17 | volumes = ec2.describe_volumes( Filters=[{'Name': 'status', 'Values': ['available']}])['Volumes']
18 |
19 | # Get all volumes for the given instance
20 | volumes_to_delete = []
21 | for volume in volumes:
22 | if 'Tags' not in volume:
23 | continue
24 | for tag in volume['Tags']:
25 | if tag['Key'] == 'Name' and tag['Value'] == GAMING_INSTANCE_NAME:
26 | volumes_to_delete.append(volume)
27 |
28 | if len(volumes_to_delete) == 0:
29 | print('No volumes found. Nothing to do! Aborting...')
30 | return
31 |
32 | # Create a snapshot of the volumes
33 | snaps_created = []
34 | for volume in volumes_to_delete:
35 | snap = ec2.create_snapshot(VolumeId=volume['VolumeId'])
36 | snap_id = snap['SnapshotId']
37 | snap_waiter = ec2.get_waiter('snapshot_completed')
38 |
39 | try:
40 | snap_waiter.wait(SnapshotIds=[snap_id], WaiterConfig={'Delay': 15,'MaxAttempts': 59 })
41 | except botocore.exceptions.WaiterError as e:
42 | print("Could not create snapshot, aborting")
43 | print(e.message)
44 | return
45 |
46 | print("Created snapshot: {}".format(snap['SnapshotId']))
47 | snaps_created.append(snap['SnapshotId'])
48 |
49 | # Tag the snapshots
50 | if len(snaps_created) > 0:
51 | ec2.create_tags(
52 | Resources=snaps_created,
53 | Tags=[
54 | {'Key': 'SnapAndDelete', 'Value': 'True'},
55 | {'Key': 'Name', 'Value': "Snapshot of " + GAMING_INSTANCE_NAME}
56 | ]
57 | )
58 |
59 | # Delete any current AMIs
60 | images = ec2.describe_images(Owners=['self'])['Images']
61 | for ami in images:
62 | if ami['Name'] == GAMING_INSTANCE_NAME:
63 | print('Deleting image {}'.format(ami['ImageId']))
64 | ec2.deregister_image(DryRun=False,ImageId=ami['ImageId'])
65 |
66 | # Remove previous snapshots of the volumes
67 | previous_snapshots = ec2.describe_snapshots(Filters=[{'Name': 'tag-key', 'Values': ['SnapAndDelete']}])['Snapshots']
68 | for snapshot in previous_snapshots:
69 | if snapshot['SnapshotId'] not in snaps_created:
70 | print("Removing previous snapshot: {}".format(snapshot['SnapshotId']))
71 | ec2.delete_snapshot(SnapshotId=snapshot['SnapshotId'])
72 |
73 | # Delete the volumes
74 | for volume in volumes_to_delete:
75 | v = res_client.Volume(volume['VolumeId'])
76 | print("Deleting EBS volume: {}, Size: {} GiB".format(v.id, v.size))
77 | v.delete()
78 |
79 | # Create a new AMI
80 | if len(snaps_created) > 0:
81 | amis_created = []
82 | ami = ec2.register_image(
83 | Name=GAMING_INSTANCE_NAME,
84 | Description=GAMING_INSTANCE_NAME + ' Automatic AMI',
85 | BlockDeviceMappings=[
86 | {
87 | 'DeviceName': '/dev/sda1',
88 | 'Ebs': {
89 | 'DeleteOnTermination': False,
90 | 'SnapshotId': snaps_created[0],
91 | 'VolumeSize': GAMING_INSTANCE_SIZE_GB,
92 | 'VolumeType': 'gp2'
93 | }
94 | },
95 | ],
96 | Architecture='x86_64',
97 | RootDeviceName='/dev/sda1',
98 | DryRun=False,
99 | VirtualizationType='hvm',
100 | EnaSupport=True #Supported instance types: current generation instance type, other than C4, D2, M4 instances smaller than m4.16xlarge, or T2. https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/enhanced-networking-ena.html
101 | #Remove # in front of "SriovNetSupport='simple'" and add a # in front of "EnaSupport=True" to use SriovNetSupport.
102 | #SriovNetSupport='simple' #Supported instance types: C3, C4, D2, I2, M4 (excluding m4.16xlarge), and R3. https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sriov-networking.html
103 | )
104 | print('Created image {}'.format(ami['ImageId']))
105 | amis_created.append(ami['ImageId'])
106 |
107 | if len(amis_created) > 0:
108 | # Tag the AMI
109 | ec2.create_tags(
110 | Resources=amis_created,
111 | Tags=[
112 | {'Key': 'SnapAndDelete', 'Value': 'True'},
113 | {'Key': 'Name', 'Value': GAMING_INSTANCE_NAME}
114 | ]
115 | )
116 |
--------------------------------------------------------------------------------
/images/2019Base.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/2019Base.png
--------------------------------------------------------------------------------
/images/SecurityGroup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/SecurityGroup.png
--------------------------------------------------------------------------------
/images/awsconfigure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/awsconfigure.png
--------------------------------------------------------------------------------
/images/createfunction.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/createfunction.png
--------------------------------------------------------------------------------
/images/createkeys.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/createkeys.png
--------------------------------------------------------------------------------
/images/decrypted.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/decrypted.png
--------------------------------------------------------------------------------
/images/doom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/doom.png
--------------------------------------------------------------------------------
/images/ec2access.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/ec2access.png
--------------------------------------------------------------------------------
/images/event1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/event1.png
--------------------------------------------------------------------------------
/images/functionrole.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/functionrole.png
--------------------------------------------------------------------------------
/images/functiontimeout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/functiontimeout.png
--------------------------------------------------------------------------------
/images/g4dnxlarge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/g4dnxlarge.png
--------------------------------------------------------------------------------
/images/instance_started.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/instance_started.png
--------------------------------------------------------------------------------
/images/launchid1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/launchid1.png
--------------------------------------------------------------------------------
/images/launchid2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/launchid2.png
--------------------------------------------------------------------------------
/images/launchtags.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/launchtags.png
--------------------------------------------------------------------------------
/images/pastedfunction.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/pastedfunction.png
--------------------------------------------------------------------------------
/images/prepcopy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/prepcopy.png
--------------------------------------------------------------------------------
/images/ps1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/ps1.png
--------------------------------------------------------------------------------
/images/ps2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/ps2.png
--------------------------------------------------------------------------------
/images/ps3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/ps3.png
--------------------------------------------------------------------------------
/images/ps5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/ps5.png
--------------------------------------------------------------------------------
/images/ps6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/ps6.png
--------------------------------------------------------------------------------
/images/ps7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/ps7.png
--------------------------------------------------------------------------------
/images/pserror.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/pserror.png
--------------------------------------------------------------------------------
/images/region.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/region.png
--------------------------------------------------------------------------------
/images/running_instances.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/running_instances.png
--------------------------------------------------------------------------------
/images/serverok.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/serverok.png
--------------------------------------------------------------------------------
/images/spot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/spot.png
--------------------------------------------------------------------------------
/images/spoterror.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/spoterror.png
--------------------------------------------------------------------------------
/images/storage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/storage.png
--------------------------------------------------------------------------------
/images/tagginginstance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/tagginginstance.png
--------------------------------------------------------------------------------
/images/testsuccess.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/testsuccess.png
--------------------------------------------------------------------------------
/images/tutorial1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/tutorial1.png
--------------------------------------------------------------------------------
/images/tutorial2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/tutorial2.png
--------------------------------------------------------------------------------
/images/tutorial3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/tutorial3.png
--------------------------------------------------------------------------------
/images/tutorial4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/tutorial4.png
--------------------------------------------------------------------------------
/images/tutorial5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/tutorial5.png
--------------------------------------------------------------------------------
/images/tutorial6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/tutorial6.png
--------------------------------------------------------------------------------
/images/tutorial7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/tutorial7.png
--------------------------------------------------------------------------------
/images/tutorial8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keithvassallomt/parsec-aws-automation/ea8fe96b367ac996385cf536189f4e17cbcd6211/images/tutorial8.png
--------------------------------------------------------------------------------
/start_server.ps1:
--------------------------------------------------------------------------------
1 | $GAMING_INSTANCE_NAME="YOUR GAMING RIG NAME GOES HERE"
2 | $LAUNCH_TEMPLATE="YOUR LAUNCH TEMPLATE ID GOES HERE"
3 |
4 | $ami=$(aws ec2 describe-images --filters Name=name,Values="$($GAMING_INSTANCE_NAME)" --output text --query 'Images[*].{ID:ImageId}')
5 |
6 | Write-Host "Launching new instance with AMI id: $($ami)"
7 | aws ec2 run-instances `
8 | --launch-template LaunchTemplateId=$($LAUNCH_TEMPLATE),Version=1 --image-id $($ami)
9 |
10 |
--------------------------------------------------------------------------------
/start_server.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | GAMING_INSTANCE_NAME="YOUR GAMING RIG NAME GOES HERE"
4 | LAUNCH_TEMPLATE="YOUR LAUNCH TEMPLATE ID GOES HERE"
5 |
6 | ami=`aws ec2 describe-images --filters Name=name,Values="$GAMING_INSTANCE_NAME" --output text --query 'Images[*].{ID:ImageId}'`
7 |
8 | echo "Launching new instance with AMI id: $ami"
9 | aws ec2 run-instances \
10 | --launch-template LaunchTemplateId=$LAUNCH_TEMPLATE,Version=1 --image-id $ami
11 |
12 |
--------------------------------------------------------------------------------