Show More
@@ -687,7 +687,9 def temporary_ec2_instances(ec2resource, | |||
|
687 | 687 | |
|
688 | 688 | |
|
689 | 689 | @contextlib.contextmanager |
|
690 |
def create_temp_windows_ec2_instances( |
|
|
690 | def create_temp_windows_ec2_instances( | |
|
691 | c: AWSConnection, config, bootstrap: bool = False | |
|
692 | ): | |
|
691 | 693 | """Create temporary Windows EC2 instances. |
|
692 | 694 | |
|
693 | 695 | This is a higher-level wrapper around ``create_temp_ec2_instances()`` that |
@@ -712,7 +714,9 def create_temp_windows_ec2_instances(c: | |||
|
712 | 714 | 'Tags': [{'Key': 'Name', 'Value': 'hg-temp-windows'}], |
|
713 | 715 | } |
|
714 | 716 | ) |
|
715 | config['UserData'] = WINDOWS_USER_DATA % password | |
|
717 | ||
|
718 | if bootstrap: | |
|
719 | config['UserData'] = WINDOWS_USER_DATA % password | |
|
716 | 720 | |
|
717 | 721 | with temporary_ec2_instances(c.ec2resource, config) as instances: |
|
718 | 722 | wait_for_ip_addresses(instances) |
@@ -1111,6 +1115,23 def ensure_windows_dev_ami( | |||
|
1111 | 1115 | with INSTALL_WINDOWS_DEPENDENCIES.open('r', encoding='utf-8') as fh: |
|
1112 | 1116 | commands.extend(l.rstrip() for l in fh) |
|
1113 | 1117 | |
|
1118 | # Schedule run of EC2Launch on next boot. This ensures that UserData | |
|
1119 | # is executed. | |
|
1120 | # We disable setComputerName because it forces a reboot. | |
|
1121 | # We set an explicit admin password because this causes UserData to run | |
|
1122 | # as Administrator instead of System. | |
|
1123 | commands.extend( | |
|
1124 | [ | |
|
1125 | r'''Set-Content -Path C:\ProgramData\Amazon\EC2-Windows\Launch\Config\LaunchConfig.json ''' | |
|
1126 | r'''-Value '{"setComputerName": false, "setWallpaper": true, "addDnsSuffixList": true, ''' | |
|
1127 | r'''"extendBootVolumeSize": true, "handleUserData": true, ''' | |
|
1128 | r'''"adminPasswordType": "Specify", "adminPassword": "%s"}' ''' | |
|
1129 | % c.automation.default_password(), | |
|
1130 | r'C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 ' | |
|
1131 | r'–Schedule', | |
|
1132 | ] | |
|
1133 | ) | |
|
1134 | ||
|
1114 | 1135 | # Disable Windows Defender when bootstrapping because it just slows |
|
1115 | 1136 | # things down. |
|
1116 | 1137 | commands.insert(0, 'Set-MpPreference -DisableRealtimeMonitoring $true') |
@@ -1135,7 +1156,9 def ensure_windows_dev_ami( | |||
|
1135 | 1156 | |
|
1136 | 1157 | print('no suitable Windows development image found; creating one...') |
|
1137 | 1158 | |
|
1138 |
with create_temp_windows_ec2_instances( |
|
|
1159 | with create_temp_windows_ec2_instances( | |
|
1160 | c, config, bootstrap=True | |
|
1161 | ) as instances: | |
|
1139 | 1162 | assert len(instances) == 1 |
|
1140 | 1163 | instance = instances[0] |
|
1141 | 1164 |
General Comments 0
You need to be logged in to leave comments.
Login now