View a markdown version of this page

配置 RES-ready AMI - 研究与工程工作室

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

配置 RES-ready AMI

借助 RES-ready Amazon 系统映像 (AMI),您可以在自定义 AMI 上预安装虚拟桌面实例 (VDI) 的 RES 依赖项。使用 RES-ready AMI 可以缩短使用预烘焙映像的 VDI 实例的启动时间。使用 EC2 Image Builder,您可以构建 AMI 并将其注册为新的软件堆栈。有关 Image Builder 的更多信息,请参阅 Image Builder 用户指南

在开始之前,必须部署最新版本的 RES

准备一个 IAM 角色以访问 RES 环境

要从 EC2 Image Builder 访问 RES 环境服务,您必须创建或修改名为的 IAM 角色 RES-EC2InstanceProfileForImageBuilder。有关配置在 Image Builder 中使用的 IAM 角色的信息,请参阅 Imag e Builder 用户指南中的 AWS Identity and Access Management (IAM)

你的角色需要:
  • 包括 Amazon EC2 服务的信任关系。

  • AmazonS3ReadOnlyAccess AmazonSSMManagedInstanceCore 和 EC2InstanceProfileForImageBuilder 政策。

创建 EC2 Image Builder 组件

按照《Image Builder 用户指南》中的说明使用 Image Builder 控制台创建组件

输入您的组件详细信息:
  1. 对于 “类型”,选择 “构建”。

  2. 对于映像操作系统 (OS),请选择 Linux 或 Windows。

  3. 在 “组件名称” 中,输入一个有意义的名称,例如research-and-engineering-studio-vdi-<operating-system>

  4. 输入组件的版本号,也可以添加描述。

    key : value
  5. 定义文档中,输入以下定义文件。如果您遇到任何错误,那么 YAML 文件对空间很敏感,很可能是原因。

    重要

    在定义文件中,如果您的 RES 环境版本不是最新版本,请将下载 URI (- source: 's3://research-engineering-studio-us-east-1/releases/latest/res-installation-scripts.tar.gz'2025.06) latest 中的替换为确切的版本号(例如)。

    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: - GPUFamily: type: string description: GPU family (NONE, NVIDIA, or AMD) default: NONE 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://research-engineering-studio-us-east-1/releases/latest/res-installation-scripts.tar.gz" destination: "/root/bootstrap/res-installation-scripts/res-installation-scripts.tar.gz" - name: RunInstallScript action: ExecuteBash onFailure: Abort maxAttempts: 3 inputs: commands: - "cd /root/bootstrap/res-installation-scripts" - "tar -xf res-installation-scripts.tar.gz" - "cd scripts/virtual-desktop-host/linux" - "/bin/bash install.sh -g {{ GPUFamily }}" - name: RunInstallPostRebootScript action: ExecuteBash onFailure: Abort maxAttempts: 3 inputs: commands: - "cd /root/bootstrap/res-installation-scripts/scripts/virtual-desktop-host/linux" - 'sed -i ''/^export AWS_DEFAULT_PROFILE="bootstrap_profile"$/d'' install_post_reboot.sh' - "/bin/bash install_post_reboot.sh -g {{ GPUFamily }}" - name: PreventAL2023FromUninstallingCronie action: ExecuteBash onFailure: Abort maxAttempts: 3 inputs: commands: - "rm -f /tmp/imagebuilder_service/crontab_installed"
    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 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://research-engineering-studio-us-east-1/releases/latest/res-installation-scripts.tar.gz' destination: '{{ build.CreateRESBootstrapFolder.inputs[0].path }}\res-installation-scripts.tar.gz' - name: RunInstallScript action: ExecutePowerShell onFailure: Abort maxAttempts: 3 inputs: commands: - 'cd {{ build.CreateRESBootstrapFolder.inputs[0].path }}' - 'tar -xf res-installation-scripts.tar.gz' - 'Import-Module .\scripts\virtual-desktop-host\windows\Install.ps1' - 'Install-WindowsEC2Instance -PrebakeAMI'
  6. 创建任何可选标签并选择创建组件

准备好您的 EC2 Image Builder 配方

EC2 Image Builder 配方定义了作为创建新映像起点的基础映像,以及定义了您添加的一组用于自定义映像并验证一切是否按预期运行的组件。您必须创建或修改配方才能构造具有必要的 RES 软件依赖项的目标 AMI。有关食谱的更多信息,请参阅管理食谱

RES 支持以下图像操作系统:

  • 亚马逊 Linux 2(x86 和 ARM64)

  • 亚马逊 Linux 2023(x86 和 ARM64)

  • RHEL 8 (x86) 和 9 (x86)

  • Rocky Linux 9 (x86)

  • Ubuntu 22.04.3 (x86)

  • Windows Server 2019、2022 (x86)

  • Windows 10、11 (x86)

Create a new recipe
  1. 打开 EC2 Image Builder 控制台,网址为https://console.aws.amazon.com/imagebuilder

  2. 在 “已保存的资源” 下,选择图片配方

  3. 选择创建映像配方

  4. 输入唯一的名称和版本号。

  5. 选择 RES 支持的基础镜像。

  6. 在 “实例配置” 下,如果未预安装 SSM 代理,请安装。在用户数据和任何其他需要的用户数据中输入信息。

  7. 对于基于 Linux 的配方,请将 Amazon-managed aws-cli-version-2-linux构建组件添加到配方中。RES 安装脚本使用提供对 DynamoDB 集群设置配置值的 VDI 访问权限。AWS CLIWindows 不需要这个组件。

  8. 添加为您的 Linux 或 Windows 环境创建的 EC2 Image Builder 组件。

    重要

    对于 Linux 环境,必须按顺序添加这些组件,并先添加aws-cli-version-2-linux构建组件。

    显示已添加构建组件的 “组件” 页面
  9. (推荐)添加 Amazon-managed simple-boot-test-<linux-or-windows>测试组件以验证 AMI 是否可以启动。这是最低限度的建议。您可以选择其他符合您要求的测试组件。

  10. 如果需要,请完成所有可选部分,添加任何其他所需的组件,然后选择 “创建配方”。

Modify a recipe

如果您已有 EC2 Image Builder 配方,则可以通过添加以下组件来使用它:

  1. 对于基于 Linux 的配方,请将 Amazon-managed aws-cli-version-2-linux构建组件添加到配方中。RES 安装脚本使用提供对 DynamoDB 集群设置配置值的 VDI 访问权限。AWS CLIWindows 不需要这个组件。

  2. 添加为您的 Linux 或 Windows 环境创建的 EC2 Image Builder 组件。

    重要

    对于 Linux 环境,必须按顺序添加这些组件,并先添加aws-cli-version-2-linux构建组件。

    显示已添加构建组件的 “组件” 页面
  3. 如果需要,请完成所有可选部分,添加任何其他所需的组件,然后选择 “创建配方”。

配置 EC2 Image Builder 基础架构

您可以使用基础设施配置来指定 Image Builder 用来构建和测试您的映像生成器映像的 Amazon EC2 基础架构。要与 RES 配合使用,您可以选择创建新的基础架构配置,也可以选择使用现有基础架构配置。

要配置 Image Builder 基础设施,请执行以下操作:
  1. 对于 IAM 角色,请输入您之前在中配置的角色准备一个 IAM 角色以访问 RES 环境

  2. 对于实例类型,请选择内存至少 4 GB 且支持所选基本 AMI 架构的类型。参见 Amazon EC2 实例类型

  3. 对于 VPC、子网和安全组,您必须允许互联网访问才能下载软件包。还必须允许访问 RES 环境的 cluster-settings DynamoDB 表和 Amazon S3 集群存储桶。

配置 Image Builder 图像管道

Image Builder 映像管道汇集了基础映像、用于构建和测试的组件、基础架构配置和分发设置。要 RES-ready 为 AMI 配置图像管道,您可以选择创建新管道或使用现有管道。有关更多信息,请参阅 Image Builder 用户指南中的创建和更新 AMI 图像管道

Create a new Image Builder pipeline
  1. 打开 Image Builder 控制台,网址为https://console.aws.amazon.com/imagebuilder

  2. 在导航窗格中,选择图像管道

  3. 选择 “创建图像管道”。

  4. 通过输入唯一的名称、可选描述、时间表和频率来指定您的管道详细信息。

  5. 在 “选择食谱” 中,选择 “使用现有食谱”,然后选择在中创建的配方准备好您的 EC2 Image Builder 配方。验证您的食谱详细信息是否正确。

  6. 在 “定义图像创建流程” 中,根据用例选择默认或自定义工作流程。在大多数情况下,默认工作流程就足够了。有关更多信息,请参阅为您的 EC2 Image Builder 管道配置图像工作流程

  7. 定义基础架构配置中,选择选择现有基础架构配置,然后选择在中创建的基础架构配置配置 EC2 Image Builder 基础架构。验证您的基础架构详细信息是否正确。

  8. 在 “定义分发设置” 中,选择 “使用服务默认值创建分发设置”。输出图像必须与您的 RES 环境AWS 区域相同。使用服务默认值,将在使用 Image Builder 的区域创建图像。

  9. 查看管道详细信息并选择创建管道

Modify an existing Image Builder pipeline
  1. 要使用现有管道,请修改详细信息以使用中创建的配方准备好您的 EC2 Image Builder 配方

  2. 选择保存更改

运行 Image Builder 图像管道

要生成配置的输出图像,必须启动图像管道。构建过程可能需要长达一个小时,具体取决于图像配方中组件的数量。

要运行图像管道,请执行以下操作:
  1. 图像管道中,选择在中创建的管道配置 Image Builder 图像管道

  2. 从 “操作” 中选择 “运行管道”。

在 RES 中注册新的软件堆栈

  1. 按照中的软件堆栈 (AMI)说明注册软件堆栈。

  2. 对于 AMI ID,请输入内置输出映像的 AMI ID 运行 Image Builder 图像管道