Scheduling EC2Launch v1 to run on every boot
To make sure that replication continues after a failover, complete the following procedure on the source instance before the first failover. The standby instance can then reach the Instance Metadata Service (IMDS). Before you begin, confirm that the instance uses EC2Launch v1.
The procedure first sets adminPasswordType to DoNothing.
With this setting, you keep your Administrator password, because EC2Launch v1 does not
reset it on each boot.
When EC2Launch v1 runs on every boot, it repeats every task that is turned on in
LaunchConfig.json, not only the routes. For example, if
setComputerName is true, EC2Launch v1 might rename the
standby instance after a failover. Review the settings in
LaunchConfig.json before you complete this
procedure.
You need administrator access to the instance to complete the following procedure. If you do not have it, ask an administrator of the instance to complete the procedure.
To schedule EC2Launch v1 to run on every boot (PowerShell)
-
On the source instance, open Windows PowerShell as an administrator.
-
To keep the Administrator password, set
adminPasswordTypetoDoNothinginC:\ProgramData\Amazon\EC2-Windows\Launch\Config\LaunchConfig.json. Run the following PowerShell commands:$config = 'C:\ProgramData\Amazon\EC2-Windows\Launch\Config\LaunchConfig.json' $json = Get-Content $config -Raw | ConvertFrom-Json $json.adminPasswordType = 'DoNothing' $json | ConvertTo-Json -Depth 10 | Set-Content $config -
To schedule EC2Launch v1 to run on every boot, run the following PowerShell command:
& 'C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1' -SchedulePerBoot
EC2Launch v1 now runs on every boot, starting with the next boot. You do not need to restart the instance now. After a failover, the standby instance can reach IMDS.
For more information about scheduling EC2Launch v1, see Schedule EC2Launch to run on every boot in the Amazon EC2 User Guide.