本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
設定 RES 就緒 AMIs
使用 RES-ready AMIs,您可以在自訂 AMI 上預先安裝虛擬桌面執行個體 VDIs) 的 RES AMIs 相依性。使用 RES-ready AMIs 可改善使用預先製作映像的 VDI 執行個體開機時間。使用 EC2 Image Builder,您可以將 AMIs 建置並註冊為新的軟體堆疊。如需映像建置器的詳細資訊,請參閱映像建置器使用者指南。
開始之前,您必須部署最新版本的 RES。
準備 IAM 角色以存取 RES 環境
若要從 EC2 Image Builder 存取 RES 環境服務,您必須建立或修改名為 RES-EC2InstanceProfileForImageBuilder 的 IAM 角色。如需有關設定 IAM 角色以在映像建置器中使用的資訊,請參閱《映像建置器使用者指南》中的 AWS Identity and Access Management (IAM)。
信任的關係實體:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
}
"Action": "sts:AssumeRole"
}
]
}
RES 政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "RESDynamoDBAccess",
"Effect": "Allow",
"Action": "dynamodb:GetItem",
"Resource": "arn:aws:dynamodb:{AWS-Region}:{AWS-Account-ID}:table/{RES-EnvironmentName}.cluster-settings",
"Condition": {
"ForAllValues:StringLike": {
"dynamodb:LeadingKeys": [
"global-settings.gpu_settings.*",
"global-settings.package_config.*"
]
}
}
},
{
"Sid": "RESS3Access",
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::{RES-EnvironmentName}-cluster-{AWS-Region}-{AWS-Account-ID}/idea/vdc/res-ready-install-script-packages/*"
}
]
}
建立 EC2 Image Builder 元件
遵循《映像建置器使用者指南》中的指示,使用映像建置器主控台建立元件。
輸入您的元件詳細資訊:
-
針對類型,選擇建置。
-
針對映像作業系統 (OS),選擇 Linux 或 Windows。
-
針對元件名稱,輸入有意義的名稱,例如 research-and-engineering-studio-vdi-<operating-system>
。
-
輸入元件的版本編號,並選擇性地新增描述。
-
在定義文件中,輸入下列定義檔案。如果您遇到任何錯誤,YAML 檔案會區分空間,而且最可能的原因。
- Linux
-
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
# with the License. A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
# and limitations under the License.
name: research-and-engineering-studio-vdi-linux
description: An RES EC2 Image Builder component to install required RES software dependencies for Linux VDI.
schemaVersion: 1.0
parameters:
- AWSAccountID:
type: string
description: RES Environment AWS Account ID
- RESEnvName:
type: string
description: RES Environment Name
- RESEnvRegion:
type: string
description: RES Environment Region
- RESEnvReleaseVersion:
type: string
description: RES Release Version
phases:
- name: build
steps:
- name: PrepareRESBootstrap
action: ExecuteBash
onFailure: Abort
maxAttempts: 3
inputs:
commands:
- 'mkdir -p /root/bootstrap/logs'
- 'mkdir -p /root/bootstrap/latest'
- name: DownloadRESLinuxInstallPackage
action: S3Download
onFailure: Abort
maxAttempts: 3
inputs:
- source: 's3://{{ RESEnvName }}-cluster-{{ RESEnvRegion }}-{{ AWSAccountID }}/idea/vdc/res-ready-install-script-packages/linux/res_linux_install_{{ RESEnvReleaseVersion }}.tar.gz'
destination: '/root/bootstrap/res_linux_install_{{ RESEnvReleaseVersion }}.tar.gz'
expectedBucketOwner: '{{ AWSAccountID }}'
- name: RunInstallScript
action: ExecuteBash
onFailure: Abort
maxAttempts: 3
inputs:
commands:
- 'tar -xvf {{ build.DownloadRESLinuxInstallPackage.inputs[0].destination }} -C /root/bootstrap/latest'
- '/bin/bash /root/bootstrap/latest/virtual-desktop-host-linux/install.sh -r {{ RESEnvRegion }} -n {{ RESEnvName }} -g NONE'
- name: FirstReboot
action: Reboot
onFailure: Abort
maxAttempts: 3
inputs:
delaySeconds: 0
- name: RunInstallPostRebootScript
action: ExecuteBash
onFailure: Abort
maxAttempts: 3
inputs:
commands:
- '/bin/bash /root/bootstrap/latest/virtual-desktop-host-linux/install_post_reboot.sh'
- name: SecondReboot
action: Reboot
onFailure: Abort
maxAttempts: 3
inputs:
delaySeconds: 0
- Windows
-
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
# with the License. A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
# and limitations under the License.
name: research-and-engineering-studio-vdi-windows
description: An RES EC2 Image Builder component to install required RES software dependencies for Windows VDI.
schemaVersion: 1.0
parameters:
- AWSAccountID:
type: string
description: RES Environment AWS Account ID
- RESEnvName:
type: string
description: RES Environment Name
- RESEnvRegion:
type: string
description: RES Environment Region
- RESEnvReleaseVersion:
type: string
description: RES Release Version
phases:
- name: build
steps:
- name: CreateRESBootstrapFolder
action: CreateFolder
onFailure: Abort
maxAttempts: 3
inputs:
- path: 'C:\Users\Administrator\RES\Bootstrap'
overwrite: true
- name: DownloadRESWindowsInstallPackage
action: S3Download
onFailure: Abort
maxAttempts: 3
inputs:
- source: 's3://{{ RESEnvName }}-cluster-{{ RESEnvRegion }}-{{ AWSAccountID }}/idea/vdc/res-ready-install-script-packages/windows/res_windows_install_{{ RESEnvReleaseVersion }}.tar.gz'
destination: '{{ build.CreateRESBootstrapFolder.inputs[0].path }}\res_windows_install_{{ RESEnvReleaseVersion }}.tar.gz'
expectedBucketOwner: '{{ AWSAccountID }}'
- name: RunInstallScript
action: ExecutePowerShell
onFailure: Abort
maxAttempts: 3
inputs:
commands:
- 'cd {{ build.CreateRESBootstrapFolder.inputs[0].path }}'
- 'Tar -xf res_windows_install_{{ RESEnvReleaseVersion }}.tar.gz'
- 'Import-Module .\virtual-desktop-host-windows\Install.ps1'
- 'Install-WindowsEC2Instance'
- name: Reboot
action: Reboot
onFailure: Abort
maxAttempts: 3
inputs:
delaySeconds: 0
-
建立任何選用標籤,然後選擇建立元件。
準備您的 EC2 Image Builder 配方
EC2 Image Builder 配方會定義基本映像,以做為建立新映像的起點,以及您新增的一組元件來自訂映像,並確認一切如預期般運作。您必須建立或修改配方,以使用必要的 RES 軟體相依性來建構目標 AMI。如需配方的詳細資訊,請參閱管理配方。
RES 支援下列映像作業系統:
- Create a new recipe
-
-
在 開啟 EC2 Image Builder 主控台https://console.aws.amazon.com/imagebuilder。
-
在已儲存的資源下,選擇映像配方。
-
選擇建立映像配方。
-
輸入唯一的名稱和版本編號。
-
選擇 RES 支援的基礎映像。
-
在執行個體組態下,如果未預先安裝 SSM 代理程式,請安裝 SSM 代理程式。在使用者資料和任何其他所需的使用者資料中輸入資訊。
-
對於 Linux 型配方,將 Amazon 受管aws-cli-version-2-linux
建置元件新增至配方。RES 安裝指令碼使用 AWS CLI 提供 DynamoDB 叢集設定組態值的 VDI 存取權。Windows 不需要此元件。
-
新增為 Linux 或 Windows 環境建立的 EC2 Image Builder 元件,然後輸入任何必要的參數值。下列參數是必要的輸入:AWSAccountID、RESEnvName、RESEnvRegion 和 RESEnvReleaseVersion。
對於 Linux 環境,您必須依先新增aws-cli-version-2-linux
建置元件的順序新增這些元件。
-
(建議) 新增 Amazon 受管simple-boot-test-<linux-or-windows>
測試元件,以確認可以啟動 AMI。這是最低建議。您可以選取其他符合您需求的測試元件。
-
視需要完成任何選用區段,新增任何其他所需的元件,然後選擇建立配方。
- Modify a recipe
-
如果您有現有的 EC2 Image Builder 配方,您可以新增下列元件來使用它:
對於 Linux 型配方,將 Amazon 受管aws-cli-version-2-linux
建置元件新增至配方。RES 安裝指令碼使用 AWS CLI 提供 DynamoDB 叢集設定組態值的 VDI 存取權。Windows 不需要此元件。
-
新增為 Linux 或 Windows 環境建立的 EC2 Image Builder 元件,然後輸入任何必要的參數值。下列參數是必要的輸入:AWSAccountID、RESEnvName、RESEnvRegion 和 RESEnvReleaseVersion。
對於 Linux 環境,您必須依先新增aws-cli-version-2-linux
建置元件的順序新增這些元件。
-
視需要完成任何選用區段,新增任何其他所需的元件,然後選擇建立配方。
您可以使用基礎設施組態來指定映像建置器用來建置和測試映像建置器映像的 Amazon EC2 基礎設施。若要搭配 RES 使用,您可以選擇建立新的基礎設施組態,或使用現有的基礎設施組態。
若要設定映像建置器基礎設施:
-
針對 IAM 角色,輸入您先前在 中設定的角色準備 IAM 角色以存取 RES 環境。
-
針對執行個體類型,選擇至少具有 4 GB 記憶體的類型,並支援您選擇的基本 AMI 架構。請參閱 Amazon EC2 執行個體類型。
-
對於 VPC、子網路和安全群組,您必須允許網際網路存取以下載軟體套件。還必須允許存取 RES 環境的 cluster-settings
DynamoDB 資料表和 Amazon S3 叢集儲存貯體。
設定映像建置器映像管道
映像建置器映像管道會組合基礎映像、用於建置和測試的元件、基礎設施組態和分發設定。若要為 RES 就緒 AMIs 設定映像管道,您可以選擇建立新的管道,或使用現有的管道。如需詳細資訊,請參閱《映像建置器使用者指南》中的建立和更新 AMI 映像管道。
- Create a new Image Builder pipeline
-
- Modify an existing Image Builder pipeline
-
執行映像建置器映像管道
若要產生設定的輸出映像,您必須啟動映像管道。建置程序可能需要長達一小時的時間,具體取決於映像配方中的元件數量。
在 RES 中註冊新的軟體堆疊