Skip to content

create_route async

create_route(
    environment_identifier: EnvironmentId,
    application_identifier: ApplicationId,
    service_identifier: ServiceId,
    route_type: RouteType,
    *,
    config_overrides: Optional[AsyncMigrationHubRefactorSpacesClientConfig] = None,
    default_route: Optional[DefaultRouteInput] = None,
    uri_path_route: Optional[UriPathRouteInput] = None,
    tags: Optional[TagMap] = None,
    client_token: Optional[ClientToken] = None,
) -> CreateRouteResponse

Creates an Amazon Web Services Migration Hub Refactor Spaces route. The account owner of the service resource is always the environment owner, regardless of which account creates the route. Routes target a service in the application. If an application does not have any routes, then the first route must be created as a DEFAULT RouteType.

When created, the default route defaults to an active state so state is not a required input. However, like all other state values the state of the default route can be updated after creation, but only when all other routes are also inactive. Conversely, no route can be active without the default route also being active.

When you create a route, Refactor Spaces configures the Amazon API Gateway to send traffic to the target service as follows:

  • URL Endpoints

    If the service has a URL endpoint, and the endpoint resolves to a private IP address, Refactor Spaces routes traffic using the API Gateway VPC link. If a service endpoint resolves to a public IP address, Refactor Spaces routes traffic over the public internet. Services can have HTTP or HTTPS URL endpoints. For HTTPS URLs, publicly-signed certificates are supported. Private Certificate Authorities (CAs) are permitted only if the CA's domain is also publicly resolvable.

    Refactor Spaces automatically resolves the public Domain Name System (DNS) names that are set in CreateService:UrlEndpoint when you create a service. The DNS names resolve when the DNS time-to-live (TTL) expires, or every 60 seconds for TTLs less than 60 seconds. This periodic DNS resolution ensures that the route configuration remains up-to-date.

    One-time health check

    A one-time health check is performed on the service when either the route is updated from inactive to active, or when it is created with an active state. If the health check fails, the route transitions the route state to FAILED, an error code of SERVICE_ENDPOINT_HEALTH_CHECK_FAILURE is provided, and no traffic is sent to the service.

    For private URLs, a target group is created on the Network Load Balancer and the load balancer target group runs default target health checks. By default, the health check is run against the service endpoint URL. Optionally, the health check can be performed against a different protocol, port, and/or path using the CreateService:UrlEndpoint parameter. All other health check settings for the load balancer use the default values described in the Health checks for your target groups in the Elastic Load Balancing guide. The health check is considered successful if at least one target within the target group transitions to a healthy state.

  • Lambda function endpoints

    If the service has an Lambda function endpoint, then Refactor Spaces configures the Lambda function's resource policy to allow the application's API Gateway to invoke the function.

    The Lambda function state is checked. If the function is not active, the function configuration is updated so that Lambda resources are provisioned. If the Lambda state is Failed, then the route creation fails. For more information, see the GetFunctionConfiguration's State response parameter in the Lambda Developer Guide.

    A check is performed to determine that a Lambda function with the specified ARN exists. If it does not exist, the health check fails. For public URLs, a connection is opened to the public endpoint. If the URL is not reachable, the health check fails.

Environments without a network bridge

When you create environments without a network bridge (CreateEnvironment:NetworkFabricType is NONE) and you use your own networking infrastructure, you need to configure VPC to VPC connectivity between your network and the application proxy VPC. Route creation from the application proxy to service endpoints will fail if your network is not configured to connect to the application proxy VPC. For more information, see Create a route in the Refactor Spaces User Guide.

Parameters:

  • environment_identifier (EnvironmentId) –

    The ID of the environment in which the route is created.

  • application_identifier (ApplicationId) –

    The ID of the application within which the route is being created.

  • service_identifier (ServiceId) –

    The ID of the service in which the route is created. Traffic that matches this route is forwarded to this service.

  • route_type (RouteType) –

    The route type of the route. DEFAULT indicates that all traffic that does not match another route is forwarded to the default route. Applications must have a default route before any other routes can be created. URI_PATH indicates a route that is based on a URI path.

  • default_route (Optional[DefaultRouteInput], default: None ) –

    Configuration for the default route type.

  • uri_path_route (Optional[UriPathRouteInput], default: None ) –

    The configuration for the URI path route type.

  • tags (Optional[TagMap], default: None ) –

    The tags to assign to the route. A tag is a label that you assign to an Amazon Web Services resource. Each tag consists of a key-value pair..

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.

Raises:

Source code in docs_src/capo_migration_hub_refactor_spaces/_services/async_migration_hub_refactor_spaces.py
async def create_route(
    self,
    environment_identifier: "capo_migration_hub_refactor_spaces.types.environment_id.EnvironmentId",
    application_identifier: "capo_migration_hub_refactor_spaces.types.application_id.ApplicationId",
    service_identifier: "capo_migration_hub_refactor_spaces.types.service_id.ServiceId",
    route_type: "capo_migration_hub_refactor_spaces.types.route_type.RouteType",
    *,
    config_overrides: Optional[AsyncMigrationHubRefactorSpacesClientConfig] = None,
    default_route: Optional[
        "capo_migration_hub_refactor_spaces.types.default_route_input.DefaultRouteInput"
    ] = None,
    uri_path_route: Optional[
        "capo_migration_hub_refactor_spaces.types.uri_path_route_input.UriPathRouteInput"
    ] = None,
    tags: Optional[
        "capo_migration_hub_refactor_spaces.types.tag_map.TagMap"
    ] = None,
    client_token: Optional[
        "capo_migration_hub_refactor_spaces.types.client_token.ClientToken"
    ] = None,
) -> "capo_migration_hub_refactor_spaces.types.create_route_response.CreateRouteResponse":
    """<p>Creates an Amazon Web Services Migration Hub Refactor Spaces route. The account owner of the service resource is always the environment owner, regardless of which account creates the route. Routes target a service in the application. If an application does not have any routes, then the first route must be created as a <code>DEFAULT</code> <code>RouteType</code>.</p> <p>When created, the default route defaults to an active state so state is not a required input. However, like all other state values the state of the default route can be updated after creation, but only when all other routes are also inactive. Conversely, no route can be active without the default route also being active.</p> <p>When you create a route, Refactor Spaces configures the Amazon API Gateway to send traffic to the target service as follows:</p> <ul> <li> <p> <b>URL Endpoints</b> </p> <p>If the service has a URL endpoint, and the endpoint resolves to a private IP address, Refactor Spaces routes traffic using the API Gateway VPC link. If a service endpoint resolves to a public IP address, Refactor Spaces routes traffic over the public internet. Services can have HTTP or HTTPS URL endpoints. For HTTPS URLs, publicly-signed certificates are supported. Private Certificate Authorities (CAs) are permitted only if the CA's domain is also publicly resolvable. </p> <p>Refactor Spaces automatically resolves the public Domain Name System (DNS) names that are set in <code>CreateService:UrlEndpoint </code>when you create a service. The DNS names resolve when the DNS time-to-live (TTL) expires, or every 60 seconds for TTLs less than 60 seconds. This periodic DNS resolution ensures that the route configuration remains up-to-date. </p> <p/> <p> <b>One-time health check</b> </p> <p>A one-time health check is performed on the service when either the route is updated from inactive to active, or when it is created with an active state. If the health check fails, the route transitions the route state to <code>FAILED</code>, an error code of <code>SERVICE_ENDPOINT_HEALTH_CHECK_FAILURE</code> is provided, and no traffic is sent to the service.</p> <p>For private URLs, a target group is created on the Network Load Balancer and the load balancer target group runs default target health checks. By default, the health check is run against the service endpoint URL. Optionally, the health check can be performed against a different protocol, port, and/or path using the <a href="https://docs.aws.amazon.com/migrationhub-refactor-spaces/latest/APIReference/API_CreateService.html#migrationhubrefactorspaces-CreateService-request-UrlEndpoint">CreateService:UrlEndpoint</a> parameter. All other health check settings for the load balancer use the default values described in the <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html">Health checks for your target groups</a> in the <i>Elastic Load Balancing guide</i>. The health check is considered successful if at least one target within the target group transitions to a healthy state.</p> <p/> </li> <li> <p> <b>Lambda function endpoints</b> </p> <p>If the service has an Lambda function endpoint, then Refactor Spaces configures the Lambda function's resource policy to allow the application's API Gateway to invoke the function.</p> <p>The Lambda function state is checked. If the function is not active, the function configuration is updated so that Lambda resources are provisioned. If the Lambda state is <code>Failed</code>, then the route creation fails. For more information, see the <a href="https://docs.aws.amazon.com/lambda/latest/dg/API_GetFunctionConfiguration.html#SSS-GetFunctionConfiguration-response-State">GetFunctionConfiguration's State response parameter</a> in the <i>Lambda Developer Guide</i>.</p> <p>A check is performed to determine that a Lambda function with the specified ARN exists. If it does not exist, the health check fails. For public URLs, a connection is opened to the public endpoint. If the URL is not reachable, the health check fails. </p> </li> </ul> <p> <b>Environments without a network bridge</b> </p> <p>When you create environments without a network bridge (<a href="https://docs.aws.amazon.com/migrationhub-refactor-spaces/latest/APIReference/API_CreateEnvironment.html#migrationhubrefactorspaces-CreateEnvironment-request-NetworkFabricType">CreateEnvironment:NetworkFabricType</a> is <code>NONE)</code> and you use your own networking infrastructure, you need to configure <a href="https://docs.aws.amazon.com/whitepapers/latest/aws-vpc-connectivity-options/amazon-vpc-to-amazon-vpc-connectivity-options.html">VPC to VPC connectivity</a> between your network and the application proxy VPC. Route creation from the application proxy to service endpoints will fail if your network is not configured to connect to the application proxy VPC. For more information, see <a href="https://docs.aws.amazon.com/migrationhub-refactor-spaces/latest/userguide/getting-started-create-role.html"> Create a route</a> in the <i>Refactor Spaces User Guide</i>.</p> <p/>

    Args:
        environment_identifier: <p>The ID of the environment in which the route is created.</p>
        application_identifier: <p>The ID of the application within which the route is being created.</p>
        service_identifier: <p>The ID of the service in which the route is created. Traffic that matches this route is forwarded to this service.</p>
        route_type: <p>The route type of the route. <code>DEFAULT</code> indicates that all traffic that does not match another route is forwarded to the default route. Applications must have a default route before any other routes can be created. <code>URI_PATH</code> indicates a route that is based on a URI path.</p>
        default_route: <p> Configuration for the default route type. </p>
        uri_path_route: <p>The configuration for the URI path route type. </p>
        tags: <p>The tags to assign to the route. A tag is a label that you assign to an Amazon Web Services resource. Each tag consists of a key-value pair.. </p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.</p>

    Raises:
        capo_migration_hub_refactor_spaces.errors.access_denied_exception.AccessDeniedException: <p>The user does not have sufficient access to perform this action. </p>
        capo_migration_hub_refactor_spaces.errors.conflict_exception.ConflictException: <p>Updating or deleting a resource can cause an inconsistent state.</p>
        capo_migration_hub_refactor_spaces.errors.internal_server_exception.InternalServerException: <p>An unexpected error occurred while processing the request.</p>
        capo_migration_hub_refactor_spaces.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request references a resource that does not exist. </p>
        capo_migration_hub_refactor_spaces.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would cause a service quota to be exceeded. </p>
        capo_migration_hub_refactor_spaces.errors.throttling_exception.ThrottlingException: <p>Request was denied because the request was throttled. </p>
        capo_migration_hub_refactor_spaces.errors.validation_exception.ValidationException: <p>The input does not satisfy the constraints specified by an Amazon Web Service. </p>
        capo_migration_hub_refactor_spaces.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_migration_hub_refactor_spaces.types.create_route_request.CreateRouteRequest]",
    ) -> AsyncOperationResponse[
        "capo_migration_hub_refactor_spaces.types.create_route_response.CreateRouteResponse"
    ]:
        import capo_migration_hub_refactor_spaces._operations.refactor_spaces.create_route

        (
            output,
            http_response,
        ) = await capo_migration_hub_refactor_spaces._operations.refactor_spaces.create_route.async_create_route(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_migration_hub_refactor_spaces.types.create_route_request.CreateRouteRequest",
    ) -> dict[str, Any]:
        import capo_migration_hub_refactor_spaces.types.create_route_request

        return capo_migration_hub_refactor_spaces.types.create_route_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_migration_hub_refactor_spaces.types.create_route_response.CreateRouteResponse",
    ) -> dict[str, Any]:
        import capo_migration_hub_refactor_spaces.types.create_route_response

        return capo_migration_hub_refactor_spaces.types.create_route_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateRoute", redact_input=_redact_input, redact_output=_redact_output
        ),
    )
    input_: capo_migration_hub_refactor_spaces.types.create_route_request.CreateRouteRequest = {
        "environment_identifier": environment_identifier,
        "application_identifier": application_identifier,
        "service_identifier": service_identifier,
        "route_type": route_type,
    }
    if default_route is not None:
        input_["default_route"] = default_route
    if uri_path_route is not None:
        input_["uri_path_route"] = uri_path_route
    if tags is not None:
        input_["tags"] = tags
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output