

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# 起動テンプレートを追加する
<a name="project-launch-template"></a>

プロジェクトを作成または編集するときは、プロジェクト設定内の**アドバンストオプション**を使用して起動テンプレートを追加できます。起動テンプレートは、セキュリティグループ、IAM ポリシー、起動スクリプトなどの追加の設定をプロジェクト内のすべての VDI インスタンスに提供します。

## ポリシーの追加
<a name="add-policies"></a>

IAM ポリシーを追加して、プロジェクトの下にデプロイされたすべてのインスタンスの VDI アクセスを制御できます。ポリシーをオンボードするには、ポリシーに次のキーと値のペアをタグ付けします。

```
res:Resource/vdi-host-policy
```

IAM ロールの詳細については、[「IAM のポリシーとアクセス許可](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html)」を参照してください。

### セキュリティグループの追加
<a name="add-security-groups"></a>

セキュリティグループを追加して、プロジェクト内のすべての VDI インスタンスの出力データとイングレスデータを制御できます。セキュリティグループをオンボードするには、セキュリティグループに次のキーと値のペアをタグ付けします。

```
res:Resource/vdi-security-group
```

セキュリティグループの詳細については、*「Amazon VPC ユーザーガイド*[AWS 」の「セキュリティグループを使用してリソースへのトラフィックを制御する](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-security-groups.html)」を参照してください。

### 起動スクリプトを追加する
<a name="project-launch-scripts"></a>

プロジェクト内のすべての VDI セッションで開始する起動スクリプトを追加できます。RES は Linux および Windows のスクリプト開始をサポートしています。スクリプトを開始するには、次のいずれかを選択できます。

**VDI の開始時にスクリプトを実行する**  
このオプションは、RES 設定またはインストールを実行する前に、VDI インスタンスの先頭でスクリプトを開始します。

**VDI が設定されている場合にスクリプトを実行する**  
このオプションは、RES 設定の完了後にスクリプトを開始します。

スクリプトは、次のオプションをサポートしています。


| スクリプト設定 | 例 | 
| --- | --- | 
| S3 URI | s3://bucketname/script.sh | 
| HTTPS URL | https://sample.samplecontent.com/sample | 
| ローカルファイル | file:///user/scripts/example.sh | 

S3 バケットでホストされているすべてのカスタムスクリプトは、次のタグでプロビジョニングする必要があります。

```
res:EnvironmentName/<res-environment>
```

**引数**には、カンマで区切られた引数を指定します。

![\[プロジェクト設定の例\]](http://docs.aws.amazon.com/ja_jp/res/latest/ug/images/res-projectconfigexample.png)


起動スクリプトのサンプルテンプレート。

------
#### [ 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"
```

------