使用 CloudFormation 创建重构空间资源 - AWS Migration Hub 重构空间

AWS Migration Hub 重构空间目前为预览版,可能会发生变化。

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

使用 CloudFormation 创建重构空间资源

AWS Migration Hub 重构空间与AWS CloudFormation,是一项服务,可帮助您对您进行建模和设置AWS这样您只需花较少的时间来创建和管理资源与基础设施。您创建一个模板来描述所有AWS所需的资源(例如环境、应用程序、服务和路由),以及AWS CloudFormation为您预置和配置这些资源。

在您使用时AWS CloudFormation,可重复使用您的模板来不断地重复设置您的 Rreation Space 资源。描述一次您的资源,然后在多个 AWS 账户和区域中反复预置相同的资源。

重构空间和 CloudFormation 模板

要为 Rreation Space 和相关服务设置和配置资源,您必须了解。AWS CloudFormation模板. 模板是 JSON 或 YAML 格式的文本文件。这些模板描述要在 AWS CloudFormation 堆栈中调配的资源。如果您不熟悉 JSON 或 YAML,可以在 AWS CloudFormation Designer 的帮助下开始使用 AWS CloudFormation 模板。有关更多信息,请参阅 AWS CloudFormation 用户指南中的什么是 AWS CloudFormation Designer?

重构 Spaces 支持在中创建环境、应用程序、服务和路由AWS CloudFormation. 有关更多信息(包括用于环境、应用程序、服务和路由的 JSON 和 YAML 模板示例),请参阅AWS Migration Hub 重构空间中的AWS CloudFormation用户指南.

模板示例

以下示例模板创建了一个 Virtual Private Cloud (VPC) 和重构 Spaces 资源。当你选择部署AWS CloudFormation模板来创建演示重构环境入门对话框中,重构空间控制台将部署以下模板。

例 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

要了解有关 AWS CloudFormation 的更多信息,请参阅以下资源: