Creating Refactor Spaces resources with CloudFormation - AWS Migration Hub Refactor Spaces

Creating Refactor Spaces resources with CloudFormation

AWS Migration Hub Refactor Spaces is integrated with AWS CloudFormation, a service that helps you to model and set up your AWS resources so that you can spend less time creating and managing your resources and infrastructure. You create a template that describes all the AWS resources that you want (such as environments, applications, services, and routes), and AWS CloudFormation provisions and configures those resources for you.

When you use AWS CloudFormation, you can reuse your template to set up your Refactor Spaces resources consistently and repeatedly. Describe your resources once, and then provision the same resources over and over in multiple AWS accounts and Regions.

Refactor Spaces and CloudFormation templates

To provision and configure resources for Refactor Spaces and related services, you must understand AWS CloudFormation templates. Templates are formatted text files in JSON or YAML. These templates describe the resources that you want to provision in your AWS CloudFormation stacks. If you're unfamiliar with JSON or YAML, you can use AWS CloudFormation Designer to help you get started with AWS CloudFormation templates. For more information, see What is AWS CloudFormation Designer? in the AWS CloudFormation User Guide.

Refactor Spaces supports creating environments, applications, services, and routes in AWS CloudFormation. For more information, including examples of JSON and YAML templates for environments, applications, services, and routes, see AWS Migration Hub Refactor Spaces in the AWS CloudFormation User Guide.

Template example

The following example template creates a virtual private cloud (VPC) and Refactor Spaces resources. When you choose to deploy an AWS CloudFormation template to create a demo refactor environment from the Getting started dialog box, the following template is deployed by the Refactor Spaces console.

Example YAML Refactor Spaces template
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 DefaultRoute: ActivationState: ACTIVE 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" ]

Learn more about CloudFormation

To learn more about AWS CloudFormation, see the following resources: