添加启动模板 - 研究与工程工作室

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

添加启动模板

创建或编辑项目时,您可以使用项目配置中的高级选项添加启动模板。启动模板为项目中的所有 VDI 实例提供了其他配置,例如安全组、IAM 策略和启动脚本。

添加策略

您可以添加 IAM 策略来控制在您的项目下部署的所有实例的 VDI 访问权限。要加入策略,请使用以下键值对标记该策略:

res:Resource/vdi-host-policy

有关 IAM 角色的更多信息,请参阅 I AM 中的策略和权限

添加安全组

您可以添加安全组来控制项目下所有 VDI 实例的出口和入口数据。要加入安全组,请使用以下键值对标记该安全组:

res:Resource/vdi-security-group

有关安全组的更多信息,请参阅 Amazon VPC 用户指南中的使用安全组控制 AWS 资源流量

添加启动脚本

您可以添加启动脚本,这些脚本将在项目中的所有 VDI 会话中启动。RES 支持 Linux 和 Windows 的脚本初始化。要启动脚本,您可以选择以下任一选项:

VDI 启动时运行脚本

在任何 RES 配置或安装运行之前,此选项在 VDI 实例的开头启动脚本。

配置 VDI 后运行脚本

此选项在 RES 配置完成后启动脚本。

脚本支持以下选项:

脚本配置 示例
S3 URI s3://bucketname/script.sh
HTTPS URL https://sample.samplecontent.com/sample
本地文件 文件:///.sh user/scripts/example

托管在 S3 存储桶上的所有自定义脚本都需要使用以下标签进行配置:

res:EnvironmentName/<res-environment>

对于参数,请提供用逗号分隔的所有参数。

项目配置示例

项目配置示例

启动脚本的示例模板。

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. #!/bin/bash echo "start_script.sh running" >> /test_scripts echo "All arguments: $@" >> /test_scripts echo "Argument count: $#" >> /test_scripts echo "Argument 1, $1" >> /test_scripts echo "Argument 2, $2" >> /test_scripts echo "end of start_script.sh" >> /test_scripts
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. #!pwsh Write-Output "configure_script.ps1 running" | Out-File -Append -FilePath "/test_scripts" Write-Output "All arguments: $args" | Out-File -Append -FilePath "/test_scripts" Write-Output "Argument count: $($args.Count)" | Out-File -Append -FilePath "/test_scripts" Write-Output "Argument 1, $($args[0])" | Out-File -Append -FilePath "/test_scripts" Write-Output "Argument 2, $($args[1])" | Out-File -Append -FilePath "/test_scripts" Write-Output "end of configure_script.ps1" | Out-File -Append -FilePath "/test_scripts"