Skip to main content

2026 年 12 月 1 日

Amazon Core Managed Instance のリソースの構成

**機能のステータス:**制限付き可用性 (LA)

概要

Horizon Cloud で Amazon Core Managed Instance (CMI) を使用するには、Windows イメージを準備する必要があります。それには、サポートされている Windows ISO を AWS にインポートし、EC2 Image Builder を使用してベース AMI を作成してから、EC2 Image Builder コンポーネント、イメージ レシピ、およびパイプラインを使用し、Horizon Agent インストーラ (HAI) で AMI をカスタマイズします。

このトピックでは、一般的な準備手順と CMI 固有のイメージ カスタマイズ ワークフローについて説明します。

**注:**この方法は、Amazon WorkSpaces Core の方法(方法 1:AWS EC2 カスタム インスタンスのインポート、方法 2、および方法 3)とは別のものです。ワークフローが異なるため、ここに記載されている手順とこれらの方法を組み合わせないでください。

一般的な準備手順

CMI 用の Windows イメージを作成する前に、次の準備タスクを順番に完了します。これらの手順は、環境、権限、およびソース イメージが AWS EC2 Image Builder で使用できる状態になっていることを確保します。

各手順の詳細については、「Horizon on AWS 用の Windows イメージを作成するための一般的な準備手順」を参照してください。

  1. Horizon on AWS でサポートされている Windows ISO の取得 - Microsoft の公式 Web サイトからサポートされている Windows ISO(Windows 11 Enterprise 25H2 や 24H2 など)をダウンロードします。

  2. Amazon S3 バケットへの Windows ISO のアップロード - AWS Image Builder からアクセス可能な Amazon S3 バケットに ISO ファイルをアップロードします。ISO ファイル拡張子は大文字である必要があります(たとえば、Windows11.ISO)。

  3. EC2 Image Builder の IAM ロールの作成 - 次の権限ポリシーを使用して IAM ロールを作成します。

    • AmazonSSMManagedInstanceCore
    • EC2InstanceProfileForImageBuilder
    • EC2InstanceProfileForImageBuilderECRContainerBuilds
  4. EC2 Image Builder インフラストラクチャ構成の作成 - インスタンス タイプ、VPC、サブネット、セキュリティ グループ、SNS トピックなど、イメージのビルドおよびテスト操作中に使用されるコンピューティング、ネットワーク、通知設定を定義します。

Windows ISO のインポートとベース AMI の作成

一般的な準備手順を完了したら、EC2 Image Builder を使用して Windows ISO を AWS にインポートし、ベースの Amazon Machine Image (AMI) を作成します。結果の AMI は、後でイメージ レシピの親イメージとして使用されます。

手順

  1. AWS マネジメント コンソールから、[EC2 Image Builder] に移動します。
  2. ナビゲーション ペインで、[イメージ] を選択します。
  3. [イメージのインポート] を選択します。
  4. [全般] セクションで、次の情報を指定します。
    • [名前] – イメージの一意の名前を入力します。
    • [バージョン] – major.minor.patch 形式を使用して、バージョン番号を指定します。
  5. [インポート タイプ] で [ISO インポート] を選択します。
  6. [ISO インポート構成] セクションで、次の詳細を指定します。
    • [S3 URI] - Windows ISO ファイルが保存されている Amazon S3 の場所を指定します。
    • [IAM ロール] - 一般的な準備手順で作成した IAM ロールを選択します。
  7. [ISO インフラストラクチャ構成] で、一般的な準備手順で作成したインフラストラクチャ構成を選択します。
  8. [イメージのインポート] を選択して ISO インポート プロセスを開始します。
  9. イメージの作成が正常に完了するまで、EC2 Image Builder のインポート ステータスを監視します。

ベース AMI の検証

ISO のインポートが完了したら、次の手順に進む前に、ベース AMI が使用可能であることを検証します。

  1. EC2 Image Builder で、[イメージ] に移動します。
  2. ISO インポートから作成されたイメージを見つけます。
  3. [前回の成功ステータス] が [使用可能] と表示されていることを確認します。

Horizon Agent インストーラによる Windows AMI のカスタマイズ

ベース AMI が作成されて検証されたら、EC2 Image Builder コンポーネント、イメージ レシピ、イメージ パイプラインを使用して、Horizon Agent インストーラでカスタマイズします。この方法は手動の RDP セッションを必要とせず、カスタマイズが自動化されます。

手順 1:カスタム EC2 Image Builder コンポーネントを作成する

EC2 Image Builder でカスタム コンポーネントを作成して、Horizon Agent のインストールと OOBE 設定の構成を自動化します。各コンポーネントは、YAML ドキュメントとして定義されます。

カスタム コンポーネントを作成するには、次の手順を実行します。

  1. EC2 Image Builder で、[コンポーネント] に移動し、[コンポーネントの作成] をクリックします。
  2. イメージ オペレーティング システムには、[Windows] を選択します。OS バージョンは ISO によって決定されるため、指定する必要はありません。
  3. KMS サーバはデフォルト値のままにします。
  4. YAML ドキュメント形式を使用して、コンポーネントの内容を定義します。
  5. [コンポーネントの作成] をクリックします。

次の 4 つのコンポーネントを作成します。これらのコンポーネントをイメージ レシピに追加する順序(次のステップ)は重要です。

コンポーネント 1:インストール前の RunOnce バックアップ

すべての HKLM RunOnce キー(64 ビットおよび Wow6432Node)を C:\Windows\Temp にバックアップし、すべての RunOnce 値を削除して、Horizon Agent インストーラーが保留中の再起動を検出しないようにします(0x643 を終了します)。Horizon Agent インストール コンポーネントの直前に、このコンポーネントを実行します。

# DISCLAIMER:
# This script/YAML file is provided as a sample for reference purposes only.
# It is not intended for production use without proper review, testing, and validation.
# Users are responsible for evaluating and modifying the content to meet their
# security, compliance, and operational requirements.
# No warranties or guarantees are provided.

name: HorizonAgentPreInstallRunOnceBackup
description: Backs up all HKLM RunOnce keys/values (64-bit and Wow6432Node) to C:\Windows\Temp, then removes all RunOnce values so the Horizon Agent installer does not detect a pending reboot (exit 0x643). Run immediately before the Horizon Agent install component.
schemaVersion: 1.0

phases:
  - name: build
    steps:
      - name: ShowRunOnceValues
        action: ExecutePowerShell
        onFailure: Continue
        inputs:
          commands:
            - |
              foreach ($p in 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce',
                             'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\RunOnce') {
                  Write-Host "== $p =="
                  Get-ItemProperty -Path $p -ErrorAction SilentlyContinue | Format-List
              }

      - name: BackupAllRunOnceKeys
        action: ExecutePowerShell
        onFailure: Abort
        inputs:
          commands:
            - |
              $targets = @(
                  @{ Reg = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce';             Ps = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce';             File = 'C:\Windows\Temp\RunOnce_HKLM_backup' },
                  @{ Reg = 'HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\RunOnce'; Ps = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\RunOnce'; File = 'C:\Windows\Temp\RunOnce_HKLM_Wow6432Node_backup' }
              )

              foreach ($t in $targets) {
                  if (-not (Test-Path $t.Ps)) {
                      Write-Host "Key not present, skipping: $($t.Reg)"
                      continue
                  }

                  $regFile = "$($t.File).reg"
                  & reg.exe export $t.Reg $regFile /y
                  if ($LASTEXITCODE -ne 0) { Write-Error "reg export failed ($LASTEXITCODE) for $($t.Reg)"; exit 1 }
                  if (-not (Test-Path $regFile)) { Write-Error "Backup file not found: $regFile"; exit 1 }
                  Write-Host "Backup written to $regFile"

                  $jsonFile = "$($t.File).json"
                  $items = @(Get-Item -Path $t.Ps) + @(Get-ChildItem -Path $t.Ps -Recurse -ErrorAction SilentlyContinue)
                  $rows = foreach ($k in $items) {
                      foreach ($n in $k.GetValueNames()) {
                          [pscustomobject]@{
                              Key   = $k.Name
                              Name  = $n
                              Type  = $k.GetValueKind($n).ToString()
                              Value = $k.GetValue($n, $null, 'DoNotExpandEnvironmentNames')
                          }
                      }
                  }
                  @($rows) | ConvertTo-Json -Depth 4 | Set-Content -Path $jsonFile -Encoding UTF8
                  Write-Host "Value inventory written to $jsonFile ($(@($rows).Count) values)"
              }

      - name: RemoveAllRunOnceValues
        action: ExecutePowerShell
        onFailure: Abort
        inputs:
          commands:
            - |
              # SAFETY: $true = log only (dry run). Set to $false to actually delete.
              $DryRun = $false

              $roots = @(
                  'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce',
                  'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\RunOnce'
              )

              foreach ($root in $roots) {
                  if (-not (Test-Path $root)) { Write-Host "Key not present, skipping: $root"; continue }

                  # Root key plus any subkeys (e.g. RunOnce\Setup). Subkeys themselves are kept; only values are removed.
                  $keys = @(Get-Item -Path $root) + @(Get-ChildItem -Path $root -Recurse -ErrorAction SilentlyContinue)
                  foreach ($k in $keys) {
                      foreach ($n in $k.GetValueNames()) {
                          if ([string]::IsNullOrEmpty($n)) { continue }   # skip (Default)
                          if ($DryRun) {
                              Write-Host "[DRY RUN] Would remove '$n' from $($k.Name)"
                          } else {
                              Remove-ItemProperty -LiteralPath $k.PSPath -Name $n -ErrorAction Stop
                              Write-Host "Removed '$n' from $($k.Name)"
                          }
                      }
                  }
              }
              exit 0

コンポーネント 2:Omnissa Horizon Agent のインストール

Omnissa Horizon Agent Installer をダウンロードしてサイレント インストールします。インストーラには耐障害性があります -- 1603 エラーが発生すると、再起動して再試行します(最大 2 回)。

# DISCLAIMER:
# This script/YAML file is provided as a sample for reference purposes only.
# It is not intended for production use without proper review, testing, and validation.
# Users are responsible for evaluating and modifying the content to meet their
# security, compliance, and operational requirements.
# No warranties or guarantees are provided.

name: InstallOmnissaHorizonAgents
description: Downloads and silently installs Omnissa Horizon Agents Installer 26.3.0 (resilient, reboot-and-retry on 1603)
schemaVersion: 1.0

phases:
  - name: build
    steps:
      - name: CheckPendingReboot
        action: ExecutePowerShell
        onFailure: Continue
        inputs:
          commands:
            - |
              $pending = @()
              if (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending') { $pending += 'CBS' }
              if (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired') { $pending += 'WindowsUpdate' }
              $pfro = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' -Name PendingFileRenameOperations -ErrorAction SilentlyContinue).PendingFileRenameOperations
              if ($pfro) { $pending += 'PendingFileRename' }
              if ($pending.Count -gt 0) {
                Write-Warning "Pending reboot detected ($($pending -join ', ')). Skipping reboot and continuing installation."
              } else {
                Write-Host "No pending reboot detected."
              }
              exit 0

      - name: DownloadHorizonAgents
        action: WebDownload
        maxAttempts: 3
        timeoutSeconds: 1800
        onFailure: Abort
        inputs:
          - source: https://softwareupdate.omnissa.com/horizoncloud-v2-agents/packages/HAI-Agent/26.3.0/40775428445/Omnissa-Horizon-Agents-Installer-26.3.0-40775428445-x64.exe
            destination: C:\Windows\Temp\Omnissa-Horizon-Agents-Installer.exe
            overwrite: true

      - name: InstallHorizonAgents
        action: ExecutePowerShell
        maxAttempts: 2
        timeoutSeconds: 3600
        onFailure: Abort
        inputs:
          commands:
            - |
              $ErrorActionPreference = 'Stop'
              $installer = 'C:\Windows\Temp\Omnissa-Horizon-Agents-Installer.exe'
              $sourceUrl = 'https://softwareupdate.omnissa.com/horizoncloud-v2-agents/packages/HAI-Agent/26.3.0/40775428445/Omnissa-Horizon-Agents-Installer-26.3.0-40775428445-x64.exe'
              $log       = 'C:\Windows\Temp\HorizonAgents_install_wrapper.log'
              $retryFile = 'C:\Windows\Temp\HorizonAgents_1603_retry.txt'   # survives reboot
              $maxRebootRetries = 2

              function Log($m) { "$(Get-Date -Format s) $m" | Out-File $log -Append; Write-Host $m }

              $retryCount = 0
              if (Test-Path $retryFile) { $retryCount = [int](Get-Content $retryFile -Raw) }
              if ($retryCount -gt 0) { Log "Resuming after reboot (1603 retry #$retryCount)." }

              # Idempotency check - skipped during 1603 retries (failed installs can leave partial uninstall entries)
              if ($retryCount -eq 0) {
                $keys = @(
                  'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
                  'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
                )
                $existing = Get-ItemProperty $keys -ErrorAction SilentlyContinue |
                  Where-Object { $_.DisplayName -like '*Omnissa Horizon*' }
                if ($existing) { Log "Already installed: $($existing.DisplayName -join ', '). Skipping."; exit 0 }
              }

              # Re-download if installer is missing after reboot
              if (-not (Test-Path $installer)) {
                Log "Installer missing. Re-downloading..."
                [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
                Invoke-WebRequest -Uri $sourceUrl -OutFile $installer -UseBasicParsing
                if (-not (Test-Path $installer)) { Log "ERROR: Re-download failed."; exit 1 }
              }

              Log "Starting install..."
              $p = Start-Process -FilePath $installer -ArgumentList '/silent','/norestart' -Wait -PassThru
              $code = $p.ExitCode
              Log "Installer exit code: $code"

              switch ($code) {
                0    { Remove-Item $retryFile -Force -ErrorAction SilentlyContinue; Log "Install succeeded."; exit 0 }
                3010 { Remove-Item $retryFile -Force -ErrorAction SilentlyContinue; Log "Install succeeded; reboot handled by next step."; exit 0 }
                1641 { Remove-Item $retryFile -Force -ErrorAction SilentlyContinue; Log "Install succeeded; installer initiated reboot."; exit 0 }
                1603 {
                  if ($retryCount -lt $maxRebootRetries) {
                    $retryCount++
                    Set-Content -Path $retryFile -Value $retryCount
                    Log "1603 received. Rebooting and retrying ($retryCount of $maxRebootRetries)..."
                    exit 3010   # AWSTOE: reboot the instance, then re-run this step
                  }
                  Log "ERROR: 1603 persisted after $maxRebootRetries reboot/retry cycles."
                  Remove-Item $retryFile -Force -ErrorAction SilentlyContinue
                  exit 1603
                }
                default { Log "ERROR: Install failed with exit code $code"; exit $code }
              }

      - name: RebootAfterInstall
        action: Reboot
        onFailure: Continue
        inputs:
          delaySeconds: 30

      - name: CleanupInstaller
        action: ExecutePowerShell
        onFailure: Continue
        inputs:
          commands:
            - |
              Remove-Item 'C:\Windows\Temp\Omnissa-Horizon-Agents-Installer.exe' -Force -ErrorAction SilentlyContinue
              Remove-Item 'C:\Windows\Temp\HorizonAgents_1603_retry.txt' -Force -ErrorAction SilentlyContinue
              exit 0

  - name: validate
    steps:
      - name: VerifyInstallation
        action: ExecutePowerShell
        onFailure: Continue
        inputs:
          commands:
            - |
              $keys = @(
                'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
                'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
              )
              $found = Get-ItemProperty $keys -ErrorAction SilentlyContinue |
                Where-Object { $_.DisplayName -like '*Omnissa Horizon*' }
              if ($found) {
                $found | ForEach-Object { Write-Host "Installed: $($_.DisplayName) $($_.DisplayVersion)" }
              } else {
                Write-Warning "Omnissa Horizon Agents not found"
              }
              exit 0

コンポーネント 3:インストール後の RunOnce のリストア

インストール前のバックアップ コンポーネントによって作成された C:\Windows\Temp バックアップからすべての HKLM RunOnce キーをリストアし、値インベントリと照合して検証してから、再起動します。

# DISCLAIMER:
# This script/YAML file is provided as a sample for reference purposes only.
# It is not intended for production use without proper review, testing, and validation.
# Users are responsible for evaluating and modifying the content to meet their
# security, compliance, and operational requirements.
# No warranties or guarantees are provided.

name: HorizonAgentPostInstallRunOnceRestore
description: Restores all HKLM RunOnce keys/values (64-bit and Wow6432Node) from the C:\Windows\Temp backups created by HorizonAgentPreInstallRunOnceBackup after the Horizon Agent install, verifies them against the value inventory, then reboots.
schemaVersion: 1.0

phases:
  - name: build
    steps:
      - name: ImportRunOnceBackups
        action: ExecutePowerShell
        onFailure: Abort
        inputs:
          commands:
            - |
              $backups = @(
                  'C:\Windows\Temp\RunOnce_HKLM_backup.reg',
                  'C:\Windows\Temp\RunOnce_HKLM_Wow6432Node_backup.reg'
              )
              $imported = 0
              foreach ($b in $backups) {
                  if (-not (Test-Path $b)) {
                      # Backup step skips keys that did not exist, so a missing file is not an error
                      Write-Host "Backup not found, skipping: $b"
                      continue
                  }
                  & reg.exe import $b
                  if ($LASTEXITCODE -ne 0) { Write-Error "reg import failed ($LASTEXITCODE) for $b"; exit 1 }
                  Write-Host "Imported $b"
                  $imported++
              }
              if ($imported -eq 0) { Write-Error "No RunOnce backup files found in C:\Windows\Temp"; exit 1 }

      - name: VerifyRestoredRunOnceValues
        action: ExecutePowerShell
        onFailure: Continue
        inputs:
          commands:
            - |
              $inventories = @(
                  @{ Json = 'C:\Windows\Temp\RunOnce_HKLM_backup.json' },
                  @{ Json = 'C:\Windows\Temp\RunOnce_HKLM_Wow6432Node_backup.json' }
              )
              $missing = 0; $checked = 0
              foreach ($i in $inventories) {
                  if (-not (Test-Path $i.Json)) { Write-Host "Inventory not found, skipping: $($i.Json)"; continue }
                  $rows = @(Get-Content -Raw -Path $i.Json | ConvertFrom-Json)
                  foreach ($r in $rows) {
                      if ($null -eq $r -or [string]::IsNullOrEmpty($r.Name)) { continue }
                      $checked++
                      $psKey = 'Registry::' + $r.Key
                      $cur = Get-ItemProperty -LiteralPath $psKey -Name $r.Name -ErrorAction SilentlyContinue
                      if ($cur) { Write-Host "Restored: $($r.Key)\$($r.Name)" }
                      else      { Write-Warning "NOT restored: $($r.Key)\$($r.Name)"; $missing++ }
                  }
              }
              Write-Host "Checked $checked values; $missing missing"

      - name: RebootAfterRestore
        action: Reboot
        onFailure: Abort
        inputs:
          delaySeconds: 60

      - name: CleanupBackups
        action: ExecutePowerShell
        onFailure: Continue
        inputs:
          commands:
            - |
              Remove-Item -Path 'C:\Windows\Temp\RunOnce_HKLM_backup.reg',
                                'C:\Windows\Temp\RunOnce_HKLM_backup.json',
                                'C:\Windows\Temp\RunOnce_HKLM_Wow6432Node_backup.reg',
                                'C:\Windows\Temp\RunOnce_HKLM_Wow6432Node_backup.json' -Force -ErrorAction SilentlyContinue
              Write-Host "Backup files removed"

コンポーネント 4:OOBE の自動構成

OOBE、UserAccounts、AutoLogon、ロケール/キーボード設定を EC2Launch v2 Sysprep 自動ファイルに追加して、セットアップ中の手動 OS 入力を回避します。

# DISCLAIMER:
# This script/YAML file is provided as a sample for reference purposes only.
# It is not intended for production use without proper review, testing, and validation.
# Users are responsible for evaluating and modifying the content to meet their
# security, compliance, and operational requirements.
# No warranties or guarantees are provided.

name: ConfigureOOBEUnattend
description: Adds OOBE, UserAccounts, AutoLogon and locale/keyboard settings to the EC2Launch v2 Sysprep unattend file
schemaVersion: 1.0

phases:
  - name: build
    steps:
      - name: UpdateEC2LaunchUnattend
        action: ExecutePowerShell
        onFailure: Abort
        inputs:
          commands:
            - |
              $path = 'C:\ProgramData\Amazon\EC2Launch\sysprep\unattend.xml'
              if (-not (Test-Path $path)) { Write-Host "ERROR: $path not found"; exit 1 }
              Copy-Item $path "$path.bak" -Force

              [xml]$xml = Get-Content $path
              $uri = 'urn:schemas-microsoft-com:unattend'
              $ns = New-Object System.Xml.XmlNamespaceManager($xml.NameTable)
              $ns.AddNamespace('u', $uri)

              $shell = $xml.SelectSingleNode("//u:settings[@pass='oobeSystem']/u:component[@name='Microsoft-Windows-Shell-Setup']", $ns)
              if (-not $shell) { Write-Host "ERROR: oobeSystem Shell-Setup component not found"; exit 1 }

              # Create/set a nested element path under a parent, e.g. Set-Node $shell @('OOBE','HideEULAPage') 'true'
              function Set-Node($parent, [string[]]$names, [string]$value) {
                $cur = $parent
                foreach ($name in $names) {
                  $child = $cur.SelectSingleNode("u:$name", $ns)
                  if (-not $child) { $child = $xml.CreateElement($name, $uri); [void]$cur.AppendChild($child) }
                  $cur = $child
                }
                $cur.InnerText = $value
              }

              # Random throwaway password generated at build time (never logged, never stored in source).
              # EC2Launch resets the Administrator password at instance launch.
              $bytes = New-Object byte[] 18
              [Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($bytes)
              $pw = [Convert]::ToBase64String($bytes) + 'aA1!'

              # UserAccounts
              Set-Node $shell @('UserAccounts','AdministratorPassword','Value') $pw
              Set-Node $shell @('UserAccounts','AdministratorPassword','PlainText') 'true'

              # AutoLogon
              Set-Node $shell @('AutoLogon','Username') 'Administrator'
              Set-Node $shell @('AutoLogon','Enabled') 'true'
              Set-Node $shell @('AutoLogon','LogonCount') '1'
              Set-Node $shell @('AutoLogon','Password','Value') $pw
              Set-Node $shell @('AutoLogon','Password','PlainText') 'true'

              # OOBE
              $oobe = [ordered]@{
                HideEULAPage             = 'true'
                ProtectYourPC            = '3'
                HideWirelessSetupInOOBE  = 'true'
                HideOnlineAccountScreens = 'true'
                NetworkLocation          = 'Work'
              }
              foreach ($k in $oobe.Keys) { Set-Node $shell @('OOBE', $k) $oobe[$k] }

              # Locale / keyboard (pre-answers the Country, Keyboard layout and Second keyboard OOBE pages)
              $settingsNode = $shell.ParentNode
              $intl = $settingsNode.SelectSingleNode("u:component[@name='Microsoft-Windows-International-Core']", $ns)
              if (-not $intl) {
                $intl = $xml.CreateElement('component', $uri)
                $attrs = [ordered]@{ name='Microsoft-Windows-International-Core'; processorArchitecture='amd64'; publicKeyToken='31bf3856ad364e35'; language='neutral'; versionScope='nonSxS' }
                foreach ($a in $attrs.Keys) { $intl.SetAttribute($a, $attrs[$a]) }
                [void]$settingsNode.AppendChild($intl)
              }
              $locale = [ordered]@{
                InputLocale  = '0409:00000409'   # single US keyboard; no secondary layout page
                SystemLocale = 'en-US'
                UILanguage   = 'en-US'
                UserLocale   = 'en-US'           # sets country/region format
              }
              foreach ($k in $locale.Keys) { Set-Node $intl @($k) $locale[$k] }

              $xml.Save($path)
              Write-Host "Updated $path"

  - name: validate
    steps:
      - name: VerifyUnattendSettings
        action: ExecutePowerShell
        onFailure: Abort
        inputs:
          commands:
            - |
              $path = 'C:\ProgramData\Amazon\EC2Launch\sysprep\unattend.xml'
              [xml]$xml = Get-Content $path
              $ns = New-Object System.Xml.XmlNamespaceManager($xml.NameTable)
              $ns.AddNamespace('u', 'urn:schemas-microsoft-com:unattend')
              $base = "//u:settings[@pass='oobeSystem']/u:component[@name='Microsoft-Windows-Shell-Setup']"
              $ic   = "//u:settings[@pass='oobeSystem']/u:component[@name='Microsoft-Windows-International-Core']"

              $checks = [ordered]@{
                "$base/u:OOBE/u:HideEULAPage"             = 'true'
                "$base/u:OOBE/u:ProtectYourPC"            = '3'
                "$base/u:OOBE/u:HideWirelessSetupInOOBE"  = 'true'
                "$base/u:OOBE/u:HideOnlineAccountScreens" = 'true'
                "$base/u:OOBE/u:NetworkLocation"          = 'Work'
                "$base/u:AutoLogon/u:Username"            = 'Administrator'
                "$base/u:AutoLogon/u:Enabled"             = 'true'
                "$base/u:AutoLogon/u:LogonCount"          = '1'
                "$ic/u:InputLocale"                       = '0409:00000409'
                "$ic/u:SystemLocale"                      = 'en-US'
                "$ic/u:UILanguage"                        = 'en-US'
                "$ic/u:UserLocale"                        = 'en-US'
              }
              $failed = $false
              foreach ($xp in $checks.Keys) {
                $n = $xml.SelectSingleNode($xp, $ns)
                if (-not $n -or $n.InnerText -ne $checks[$xp]) { Write-Host "ERROR: missing/incorrect $xp"; $failed = $true }
              }
              # Presence-only checks for password nodes (values are never printed)
              foreach ($xp in @("$base/u:UserAccounts/u:AdministratorPassword/u:Value", "$base/u:AutoLogon/u:Password/u:Value")) {
                $n = $xml.SelectSingleNode($xp, $ns)
                if (-not $n -or [string]::IsNullOrEmpty($n.InnerText)) { Write-Host "ERROR: missing $xp"; $failed = $true }
              }
              if ($failed) { exit 1 }
              Write-Host "OOBE, UserAccounts, AutoLogon and locale settings present in $path"

手順 2:イメージ レシピを作成する

コンポーネントを作成したら、ベース AMI(ISO インポートから作成)とカスタム コンポーネントを特定の順序で組み合せるイメージ レシピを作成します。

イメージを作成するには、次の手順を実行します。

  1. EC2 Image Builder で、[イメージ レシピ] に移動し、[レシピの作成] をクリックします。
  2. [ISO インポートから作成されたイメージ] をベース/親イメージとして選択します。
  3. インフラストラクチャ構成を選択します。
  4. 次の順序に従って、ビルド コンポーネントを追加します。
順序コンポーネント目的
1HorizonAgentPreInstallRunOnceBackupHAI インストーラが保留中の再起動を検出しないように RunOnce キーをバックアップする
2InstallOmnissaHorizonAgentsOmnissa Horizon Agent をインストールする
3HorizonAgentPostInstallRunOnceRestoreバックアップされた RunOnce キーをリストアする
4ConfigureOOBEUnattendOOBE、自動ログオン、ロケール設定を構成する
  1. 配布設定を選択します。
  2. [レシピの作成] をクリックします。

**重要:**コンポーネントの順序は重要です。インストール前の RunOnce バックアップは、HAI インストーラの前に実行する必要があります。これにより、インストーラは保留中の再起動を検出しません(0x643 を終了します)。バックアップされたキーを復元するには、HAI インストーラの後にインストール後の RunOnce リストアを実行する必要があります。

手順 3:イメージ パイプラインを作成する

イメージ レシピを作成したら、コンポーネント、レシピおよびインフラストラクチャ構成を組み合せるイメージ パイプラインを作成して、完成した AMI を生成します。

イメージ パイプラインを作成するには、次の手順を実行します。

  1. EC2 Image Builder で、[パイプライン] に移動し、[パイプラインの作成] をクリックします。
  2. [全般] セクションで、パイプラインの名前を入力します。
  3. 実行タイプを選択します:
    • [手動] - パイプラインをオンデマンドで実行します。
    • [スケジュール設定済み] - スケジュールに従ってパイプラインを実行します。
  4. イメージ レシピとそのバージョンを選択します。
  5. コンポーネントが正しい順序([インストール前の RunOnce] → [HAI] → [インストール後の RunOnce] → [OOBE])で表示されていることを確認します。
  6. ワークフローはデフォルトのままにします。
  7. 一般的な準備手順で作成したインフラストラクチャ構成を選択します。
  8. 配布設定を構成します(既存のものを使用または新規作成します)。
  9. [作成] をクリックします。

パイプライン ワークフロー ステージ:

  • [ビルド] - ビルド インスタンスを起動し、SSM エージェントの準備を待機し、ビルド コンポーネントを実行し、カスタマイズされたインスタンスから AMI を作成し、ビルド インスタンスを終了します。
  • [テスト] - 新しい AMI から新規のインスタンスを起動し、テスト コンポーネントを実行して、結果を収集します。いずれかのテストに失敗すると、イメージは失敗としてマークされます。
  • [分散](オプション)- AMI をターゲット リージョンにコピーし、共有設定を適用します。

パイプラインを実行するには、次の手順を実行します。

  1. パイプラインを選択し、[アクション] > [パイプラインの実行] を選択します。
  2. ワークフロー エンジンは、[ビルド] → [テスト] → [配布] の順にオーケストレーションします。
  3. 出力イメージを表示するには、[パイプライン] > [出力イメージ] を選択し、バージョンを選択します。[出力リソース] に、AMI ID が表示されます。

EC2 Image Builder パイプラインの構築に関するその他のガイダンスについては、AWS Builder Center の記事「Amazon WorkSpaces 用の EC2 Image Builder パイプラインの構築 -- ステップバイステップ ガイド」を参照してください。

手順 4:イメージを検証し、Horizon Cloud IMS に登録する

パイプラインが完了したら、イメージを検証し、CMI ベースのイメージ作成のために Horizon Cloud に登録します。

  1. EC2 Image Builder で、パイプラインに移動し、イメージのステータスが [使用可能] と表示されていることを確認します。
  2. (オプション)作成した AMI からテスト インスタンスを起動して、構成を確認します。
    • AMI を選択し、[AMI からのインスタンスの起動] をクリックします。
    • キー ペアの詳細を指定します。
    • インスタンスにログインし、Horizon Agent とすべての構成が正しいことを確認します。
  3. 確認したら、CMI ベースのイメージ作成のために Horizon Cloud Image Management Service (IMS) に AMI を登録します。詳細については、Horizon Cloud Console のイメージのインポート ワークフローを参照してください。

**注:**Horizon Cloud での CMI イメージの登録については、別途ドキュメントを参照してください。登録手順については、「AMI を使用した AWS CMI イメージの登録」を参照してください。

関連資料

このページは役に立ちましたか?

このトピックについてフィードバックを送信

このトピックは役に立ちましたか?

個人情報や機密情報は入力しないでください。

リンクを生成しています…