

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

# を使用して Amazon WorkSpaces アプリケーションリソースの作成を自動化する AWS CloudFormation
<a name="automate-the-creation-of-appstream-2-0-resources-using-aws-cloudformation"></a>

*Ram Kandaswamy (Amazon Web Services)*

## 概要
<a name="automate-the-creation-of-appstream-2-0-resources-using-aws-cloudformation-summary"></a>

このパターンでは、 [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) テンプレート AWS クラウド を使用して での [Amazon WorkSpaces アプリケーション](https://aws.amazon.com/workspaces/applications/)リソースの作成を自動化するコードサンプルと手順を示します。このパターンは、 CloudFormation スタックを使用して、Image Builder、イメージ、フリートインスタンス、スタックなどの WorkSpaces アプリケーションアプリケーションリソースの作成を自動化する方法を示しています。デスクトップまたはアプリケーション配信モードを使用して、HTML5-compliantのブラウザで WorkSpaces アプリケーションアプリケーションをエンドユーザーにストリーミングできます。

## 前提条件と制限
<a name="automate-the-creation-of-appstream-2-0-resources-using-aws-cloudformation-prereqs"></a>

**前提条件**
+ アクティブな AWS アカウント
+ WorkSpaces アプリケーションの利用規約の承諾
+ [フリート、スタック](https://docs.aws.amazon.com/appstream2/latest/developerguide/managing-stacks-fleets.html)、[Image Builder](https://docs.aws.amazon.com/appstream2/latest/developerguide/managing-image-builders.html) などの WorkSpaces アプリケーションリソースに関する基本的な知識

**制限事項**
+ WorkSpaces アプリケーションインスタンスに関連付けられた [AWS Identity and Access Management](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html) (IAM) ロールは、そのインスタンスの作成後に変更することはできません。
+ Image Builder の作成後に WorkSpaces Applications Image Builder インスタンスのプロパティ ([サブネット](https://docs.aws.amazon.com/vpc/latest/userguide/configure-subnets.html#subnet-basics)や[セキュリティグループ](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-security-groups.html)など) を変更することはできません。

## アーキテクチャ
<a name="automate-the-creation-of-appstream-2-0-resources-using-aws-cloudformation-architecture"></a>

次の図は、 CloudFormation テンプレートを使用して WorkSpaces アプリケーションリソースの作成を自動化する方法を示しています。

![\[WorkSpaces アプリケーションリソースを自動的に作成するためのワークフロー。\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/images/pattern-img/4f0205f5-5b91-4832-9f0f-2135ae866226/images/cb578939-d9af-4f60-93c9-286881df4c3a.png)


この図表は、次のワークフローを示しています:

1. このパターンの[追加情報](#automate-the-creation-of-appstream-2-0-resources-using-aws-cloudformation-additional)セクションの YAML コードに基づいて CloudFormation テンプレートを作成します。

1.  CloudFormation テンプレートは CloudFormation テストスタックを作成します。

   1. (オプション) WorkSpaces アプリケーションを使用して Image Builder インスタンスを作成します。

   1. (オプション) カスタムソフトウェアを使用して Windows イメージを作成します。

1.  CloudFormation スタックは WorkSpaces Applications フリートインスタンスとスタックを作成します。

1. WorkSpaces アプリケーションリソースを HTML5-compliantのブラウザでエンドユーザーにデプロイします。

## ツール
<a name="automate-the-creation-of-appstream-2-0-resources-using-aws-cloudformation-tools"></a>
+ [Amazon WorkSpaces Applications](https://docs.aws.amazon.com/appstream2/latest/developerguide/what-is-appstream.html) は、どこからでもデスクトップアプリケーションに瞬時にアクセスできるフルマネージド型のアプリケーションストリーミングサービスです。WorkSpaces Applications は、アプリケーションのホストと実行に必要な AWS リソースを管理し、自動的にスケールし、オンデマンドでユーザーへのアクセスを提供します。
+ [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) は、 AWS リソースのモデル化とセットアップ、迅速かつ一貫したプロビジョニング、ライフサイクル全体の管理に役立ちます。リソースを個別に管理する代わりに、テンプレートを使用してリソースとその依存関係を記述し、それらをスタックとしてまとめて起動して設定できます。複数の および にまたがるスタックを管理 AWS アカウント およびプロビジョニングできます AWS リージョン。

## ベストプラクティス
<a name="automate-the-creation-of-appstream-2-0-resources-using-aws-cloudformation-best-practices"></a>
+ **Image Builder のネットワークアクセスを正しく設定**する – アウトバウンドのみのインターネットアクセスに NAT ゲートウェイを使用して、適切なインターネットアクセスで Virtual Private Cloud (VPC) サブネットで Image Builder を起動します。

  イメージを作成する前に、必要なリソース (アプリケーションサーバー、データベース、ライセンスサーバーなど) へのネットワーク接続をテストします。VPC ルートテーブルで、必要なすべてのネットワークリソースへの接続が許可されていることを確認します。詳細については、WorkSpaces アプリケーションドキュメントの[「インターネットアクセス](https://docs.aws.amazon.com/appstream2/latest/developerguide/internet-access.html)」を参照してください。
+ フリー**ト容量をサービスクォータに対してプロアクティブにモニタリング**する – WorkSpaces Applications インスタンスタイプとサイズクォータは ごと AWS アカウント、 ごとです AWS リージョン。同じリージョン内に同じインスタンスタイプとサイズを使用するフリートが複数存在する場合、そのリージョン内のすべてのフリートインスタンスの総数は、該当するクォータ以下でなければなりません。詳細については、WorkSpaces [アプリケーションドキュメントの「フリートのトラブルシューティング](https://docs.aws.amazon.com/appstream2/latest/developerguide/troubleshooting-fleets.html)」を参照してください。
+ **フリートデプロイ前に Image Builder テストモードでアプリケーションをテスト**する – イメージを作成してフリートにデプロイする前に、必ず Image Builder テストモードでアプリケーションを検証します。テストモードは、エンドユーザーがフリートインスタンスに対して持つ制限されたアクセス許可をシミュレートします。詳細については、WorkSpaces アプリケーションドキュメントの[「Image Builders のトラブルシューティング](https://docs.aws.amazon.com/appstream2/latest/developerguide/troubleshooting-image-builder.html#troubleshooting-07)」を参照してください。

## エピック
<a name="automate-the-creation-of-appstream-2-0-resources-using-aws-cloudformation-epics"></a>

### (オプション) WorkSpaces アプリケーションイメージを作成する
<a name="optional-create-a-aas2-image"></a>


| タスク | 説明 | 必要なスキル | 
| --- | --- | --- | 
| カスタムソフトウェアをインストールしてイメージを作成します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/automate-the-creation-of-appstream-2-0-resources-using-aws-cloudformation.html)Windows AppLocker 機能を使用してイメージをさらにロックダウンすることを検討してください。 | AWS DevOps、クラウドアーキテクト | 

### CloudFormation テンプレートをデプロイする
<a name="deploy-the-cfn-template"></a>


| タスク | 説明 | 必要なスキル | 
| --- | --- | --- | 
|  CloudFormation テンプレートを更新します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/automate-the-creation-of-appstream-2-0-resources-using-aws-cloudformation.html) | AWS システム管理者、クラウド管理者、クラウドアーキテクト、AWS 全般、AWS 管理者 | 
| テンプレートを使用して CloudFormation スタックを作成します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/automate-the-creation-of-appstream-2-0-resources-using-aws-cloudformation.html) | アプリ所有者、AWS システム管理者、Windows エンジニア | 

## トラブルシューティング
<a name="automate-the-creation-of-appstream-2-0-resources-using-aws-cloudformation-troubleshooting"></a>


| 問題 | ソリューション | 
| --- | --- | 
| さまざまな問題 | 詳細については、WorkSpaces アプリケーションドキュメントの[「トラブルシューティング](https://docs.aws.amazon.com/appstream2/latest/developerguide/troubleshooting.html)」を参照してください。 | 

## 関連リソース
<a name="automate-the-creation-of-appstream-2-0-resources-using-aws-cloudformation-resources"></a>

**リファレンス**
+ [Amazon WorkSpaces アプリケーションの使用を開始する: サンプルアプリケーションのセットアップ](https://docs.aws.amazon.com/appstream2/latest/developerguide/getting-started.html)
+ [Amazon WorkSpaces アプリケーションフリートとスタックを作成する](https://docs.aws.amazon.com/appstream2/latest/developerguide/set-up-stacks-fleets.html)

**チュートリアルと動画**
+ [Amazon WorkSpaces アプリケーションユーザーワークフロー](https://www.youtube.com/watch?v=hVGQ87-Uhrc)
+ [レガシー Windows Forms アプリを Amazon WorkSpaces アプリケーションに移行する方法](https://www.youtube.com/watch?v=CIImtS2iVbg)
+ [AWS re:Invent 2018: Amazon WorkSpaces アプリケーションでデスクトップアプリケーションを安全に配信する (BAP201)](https://www.youtube.com/watch?v=xNIyc_inOhM)

## 追加情報
<a name="automate-the-creation-of-appstream-2-0-resources-using-aws-cloudformation-additional"></a>

次のコードは、WorkSpaces アプリケーションリソースを自動的に作成するために使用できる CloudFormation テンプレートの例です。

```
AWSTemplateFormatVersion: 2010-09-09
Parameters:
  SubnetIds:
    Type: 'List<AWS::EC2::Subnet::Id>'
  testSecurityGroup:
    Type: 'AWS::EC2::SecurityGroup::Id'
  ImageName:
    Type: String
Resources:
  
  AppStreamFleet:
    Type: 'AWS::AppStream::Fleet'
    Properties:
      ComputeCapacity:
        DesiredInstances: 5
      InstanceType: stream.standard.medium
      Name: appstream-test-fleet
      DisconnectTimeoutInSeconds: 1200
      FleetType: ON_DEMAND
      IdleDisconnectTimeoutInSeconds: 1200
      ImageName: !Ref ImageName
      MaxUserDurationInSeconds: 345600
      VpcConfig:
        SecurityGroupIds:
          - !Ref testSecurityGroup
        SubnetIds: !Ref SubnetIds
  AppStreamStack:
    Type: 'AWS::AppStream::Stack'
    Properties:
      Description: AppStream stack for test
      DisplayName: AppStream test Stack
      Name: appstream-test-stack
      StorageConnectors:
        - ConnectorType: HOMEFOLDERS
      UserSettings:
        - Action: CLIPBOARD_COPY_FROM_LOCAL_DEVICE
          Permission: ENABLED
        - Action: CLIPBOARD_COPY_TO_LOCAL_DEVICE
          Permission: ENABLED
        - Action: FILE_DOWNLOAD
          Permission: ENABLED
        - Action: PRINTING_TO_LOCAL_DEVICE
          Permission: ENABLED
  AppStreamFleetAssociation:
    Type: 'AWS::AppStream::StackFleetAssociation'
    Properties:
      FleetName: appstream-test-fleet
      StackName: appstream-test-stack
    DependsOn:
      - AppStreamFleet
      - AppStreamStack
```