

AWS Migration Hub Refactor Spaces はプレビューリリースであり、変更される可能性があります。

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

# CloudFormation を使用したリファクタリングスペースリソースの作成
<a name="creating-resources-with-cloudformation"></a>

AWS Migration Hub ファクタリングスペースはAWS CloudFormationのモデル化およびセットアップに役立つサービスです。AWSリソースとインフラストラクチャの作成と管理の所要時間を短縮できるようにリソース。すべての内容を説明するテンプレートを作成します。AWS必要なリソース (環境、アプリケーション、サービス、ルートなど)、CloudFormationそれらのリソースをプロビジョニングして、設定します。

あなたが使うときCloudFormationでは、テンプレートを再利用して、リファクタリングスペースリソースを同じように繰り返してセットアップできます。リソースを一度記述すると、同じリソースを複数の AWS アカウントおよびリージョンで何度でも繰り返してプロビジョニングできます。

## スペースと CloudFormation テンプレートをリファクタリングする
<a name="working-with-templates"></a>

リファクタリングスペースおよび関連サービスのリソースをプロビジョニングして設定するには、[CloudFormationテンプレート](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-guide.html)。テンプレートは、JSON または YAML 形式のテキストファイルです。これらのテンプレートは、CloudFormation スタックでプロビジョニングするリソースについて記述します。JSON または YAML に詳しくない場合は、CloudFormation Designer を使用して CloudFormation テンプレートの使用を開始できます。詳細については、*AWS CloudFormation ユーザーガイド*の [CloudFormationDesigner とは](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/working-with-templates-cfn-designer.html)を参照してください。

リファクタリングスペースでは、環境、アプリケーション、サービス、ルートの作成がサポートされています。CloudFormation。環境、アプリケーション、サービス、ルートの JSON および YAML テンプレートの例を含む詳細については、「」を参照してください。[AWS Migration Hub のリファクタリング](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)の*AWS CloudFormationユーザーガイド*。

### テンプレートの例
<a name="working-with-templates-example"></a>

次のテンプレート例では、Virtual Private Cloud (VPC) リソースとリファクタリングスペースのリソースを作成します。をデプロイすることを選択した場合CloudFormationからデモリファクタリング環境を作成するためのテンプレート開始方法ダイアログボックスでは、次のテンプレートがスペースのリファクタリングコンソールによって展開されます。

**Example YAML リファクタリングスペーステンプレート**  

```
AWSTemplateFormatVersion: '2010-09-09'
Description: This creates resources in one account.
Resources:
  VPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.2.0.0/16
      Tags:
        - Key: Name
          Value: VpcForRefactorSpaces
  PrivateSubnet1:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref VPC
      AvailabilityZone: !Select [ 0, !GetAZs  '' ]
      CidrBlock: 10.2.1.0/24
      MapPublicIpOnLaunch: false
      Tags:
        - Key: Name
          Value: RefactorSpaces Private Subnet (AZ1)
  PrivateSubnet2:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref VPC
      AvailabilityZone: !Select [ 1, !GetAZs  '' ]
      CidrBlock: 10.2.2.0/24
      MapPublicIpOnLaunch: false
      Tags:
        - Key: Name
          Value: RefactorSpaces Private Subnet (AZ2)
  RefactorSpacesTestEnvironment:
    Type: AWS::RefactorSpaces::Environment
    DeletionPolicy: Delete
    Properties:
      Name: EnvWithMultiAccountServices
      NetworkFabricType: TRANSIT_GATEWAY
      Description: "This is a test environment"
  TestApplication:
    Type: AWS::RefactorSpaces::Application
    DeletionPolicy: Delete
    DependsOn:
      - PrivateSubnet1
      - PrivateSubnet2
    Properties:
      Name: proxytest
      EnvironmentIdentifier: !Ref RefactorSpacesTestEnvironment
      VpcId: !Ref VPC
      ProxyType: API_GATEWAY
      ApiGatewayProxy:
        EndpointType: "REGIONAL"
        StageName: "admintest"
  AdminAccountService:
    Type: AWS::RefactorSpaces::Service
    DeletionPolicy: Delete
    Properties:
      Name: AdminAccountService
      EnvironmentIdentifier: !Ref RefactorSpacesTestEnvironment
      ApplicationIdentifier: !GetAtt TestApplication.ApplicationIdentifier
      EndpointType: URL
      VpcId: !Ref VPC
      UrlEndpoint:
        Url: "http://aws.amazon.com"
  RefactorSpacesDefaultRoute:
    Type: AWS::RefactorSpaces::Route
    Properties:
      RouteType: "DEFAULT"
      EnvironmentIdentifier: !Ref RefactorSpacesTestEnvironment
      ApplicationIdentifier: !GetAtt TestApplication.ApplicationIdentifier
      ServiceIdentifier: !GetAtt AdminAccountService.ServiceIdentifier
  RefactorSpacesURIRoute:
    Type: AWS::RefactorSpaces::Route
    DependsOn: 'RefactorSpacesDefaultRoute'
    Properties:
      RouteType: "URI_PATH"
      EnvironmentIdentifier: !Ref RefactorSpacesTestEnvironment
      ApplicationIdentifier: !GetAtt TestApplication.ApplicationIdentifier
      ServiceIdentifier: !GetAtt AdminAccountService.ServiceIdentifier
      UriPathRoute:
        SourcePath: "/cfn-created-route"
        ActivationState: ACTIVE
        Methods: [ "GET" ]
```

## CloudFormation の詳細情報
<a name="learn-more-cloudformation"></a>

CloudFormationの詳細については、以下のリソースを参照してください。
+ [AWS CloudFormation](https://aws.amazon.com/cloudformation/)
+ [AWS CloudFormation ユーザーガイド](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html)
+ [CloudFormation API リファレンス](https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/Welcome.html)
+ [AWS CloudFormation コマンドラインインターフェイスユーザーガイド](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/what-is-cloudformation-cli.html)