Improve EC2 Windows launch experience by upgrading the launch agent to the latest EC2Launch v2
EC2Launch v2 is the latest Windows launch agent offered by AWS. It is the upgraded version of earlier launch agents, EC2Config and EC2Launch v1. EC2Launch v2 comes with more features that allow better control over the launch experience of Amazon Elastic Compute Cloud (Amazon EC2) Windows instances. It makes the launch process consistent, more programmable, and more customizable. AWS customers can take advantage of these features to manage scalable workloads while lowering operational overhead and cost.
In this blog post, we will talk about how you can use EC2Launch v2 in the EC2 Windows instances launch process and how to utilize new features in EC2Launch v2.
What is a launch agent?
Launch agent handles the instance launch experience. Launch agent plays a crucial role in making the instance launch experience smooth and controllable for users. Launch agent runs during instance startup and performs tasks that are crucial for EC2 Windows instances to operate properly in Amazon EC2. For example, it generates the admin password, sets network routes, and executes user data.
The latest launch agent for Windows Server is EC2Launch v2. The earlier versions – EC2Config and EC2Launch v1 – continue to function as normal. For a detailed comparison, visit this webpage.
Why should you upgrade to EC2Launch v2?
EC2Launch v2 makes the launch experience consistent, more programmable, and more customizable.
New and Improved Features – EC2Launch v2 has new features, such as supporting 60KB of compressed user data and assigning a volume name and drive letter to non-boot partitions.
Faster Bootup – EC2Launch v2 runs as a Windows service. Instances running EC2Launch v2 reach a usable state 14% faster than those using EC2Launch v1 and 5% faster than those using EC2Config.
Consistency – EC2Launch v2 is supported on all Windows Server versions from Windows Server 2008 and up. For a full list of supported operating systems, please visit this webpage. This provides consistency by using the same launch agent across different versions and editions of Windows Server.
Programmability and Customizability – EC2Launch v2 gives more control to developers and system administrators during the launch process of Windows instances. For example, you can now configure the order of the tasks that EC2Launch v2 runs, and each task now has its own event viewer entry so it can be programmatically consumed.
Which AMIs have EC2Launch v2?
Users can access EC2Launch v2 through AMIs offered by AWS. All Amazon Machine Images (AMI) with Windows Server 2022 include EC2Launch v2 by default. In addition, several stock AMIs for Windows Server 2012, 2016, and 2019 come with EC2Launch v2 preinstalled. For the full list, refer to this webpage.
You can install EC2Launch v2 as the launch agent for any EC2 Windows instance, either currently running or newly spun up.
EC2Launch v2 agent tasks and features
EC2Launch v2 fully supports use cases of EC2Config and EC2Launch v1. Popular tasks – such as setting computer name, initializing volumes, and setting drive letters – are still available. After an instance starts up, users can retrieve the password from the Amazon EC2 console and log into the instance.
EC2Launch v2 also supports new tasks and features that were in high demand. You can optimize ENA settings and enable OpenSSH. You can pass in up to 60KB of compressed user data, more than the 16KB allowed by EC2Config and EC2Launch v1. Execution status of tasks are streamed to Windows Event Logs under
Applications and Services Logs\Amazon EC2Launch. Each EC2Launch v2 event and task status has a unique Event ID so it can be programmatically consumed. A fragment of the Windows Event Log focused on EC2Launch V2 events is shown in Figure 1. For a feature comparison of all 3 launch agents, see Compare Amazon EC2 launch services.
You can configure tasks to run at each boot by using the EC2Launch v2 settings dialog box or modifying the configuration file directly at
$env:ProgramData/Amazon/EC2Launch/config/agent-config.yml. Both options are shown in Figure 2. For a complete list of tasks, see EC2Launch v2 task configuration.
You can customize instances by configuring tasks in the User data section, as shown in Figure 3. For supported user data format, see Example: user data.
How to upgrade to the latest EC2Launch v2
You can upgrade to EC2Launch v2 by manual install, EC2Launch migration tool, by installation from SSM Distributor, or by installation as an EC2 Image Builder component. Depending on your use case, you may want to take a different upgrade path. We have summarized a few use cases for each method in the table below:
|Upgrade method||Use case|
|Manual install||You are upgrading a single instance and/or want to use a traditional Windows MSI installer to do the upgrade.|
|EC2Launch migration tool||You want to upgrade from EC2Config or EC2Launch and keep some previous configurations.|
|AWSEC2Launch-RunMigration SSM document||You are upgrading a group of instances based on their tags or instances that are part of a resource group and keep some previous configurations.|
|SSM Distributor||You are upgrading a group of instances based on their tags or instances that are part of a resource group.|
|EC2 Image Builder component||You are using EC2 Image Builder to maintain and upgrade your golden Windows AMIs.|
To install the latest version of EC2Launch v2, you can download MSI installer and run it.
Upgrade using EC2Launch Migration Tool
We have released the EC2Launch Migration Tool to help migrate instances from EC2Config and EC2Launch v1 to EC2Launch v2. The migration tool has two modes, dry run mode and installation mode. Dry run mode will check if the installed agent is a standard install. Installation mode will uninstall EC2Config and EC2Launch v1 and install EC2Launch v2. It will optionally install a user-provided configuration or the default one if none is provided.
You can download the following versions of the tool:
After you downloaded the migration tool, extract its content and run install.ps1, as shown in Figure 4.
Note: The migration tool also migrates configurations from EC2launch v1 or EC2Config to EC2Launch v2. For details on how these configurations are migrated, visit this page.
Upgrade using SSM distributor
You can use AWS Systems Manager Distributor to upgrade your launch agent from previous versions (EC2Launch v1 or EC2Config) to EC2Launch v2.
Here we have an EC2 instance that is running EC2Launch v1 (Figure 5):
EC2Launch v1 is a set of Powershell scripts located under C:\ProgramData\Amazon\EC2-Windows\Launch, which are called at startup using Windows Task Scheduler.
1. From the list of services on AWS console, select Systems Manager.
2. Select Distributor from the left pane in Systems Manager console.
3. Select AWSEC2Launch-Agent from the list of packages under Owned by Amazon and select Install one time.
4. A new browser tab with AWS Systems Manager run command opens with required parameters prepopulated.
5. Select instances. Here we are manually selecting an instance with EC2Launch v1. You can also select instances by instance tags or resource group.
6. Select Run.
7. Wait for the upgrade run command to complete. This should only take few minutes.
After connecting to the instance, we can see EC2Launch v2 was installed and EC2Launch v1 was uninstalled. EC2Launch v2 now runs as a Windows service, and the EC2Launch v1 scheduled task was removed.
In this blog post, we covered what different EC2 Windows launch agents are and why you should upgrade to the latest version, EC2Launch v2. We also covered different methods to upgrade to EC2Launch v2, including manual installation, upgrade with EC2Launch Migration tool, and installation with AWS Systems Manager Distributor.
Further reading and references:
AWS can help you assess how your company can get the most out of cloud. Join the millions of AWS customers that trust us to migrate and modernize their most important applications in the cloud. To learn more on modernizing Windows Server or SQL Server, visit Windows on AWS. Contact us to start your modernization journey today.