Skip to content

create_environment async

create_environment(
    name: EnvironmentName,
    network_fabric_type: NetworkFabricType,
    *,
    config_overrides: Optional[AsyncMigrationHubRefactorSpacesClientConfig] = None,
    description: Optional[Description] = None,
    tags: Optional[TagMap] = None,
    client_token: Optional[ClientToken] = None,
) -> CreateEnvironmentResponse

Creates an Amazon Web Services Migration Hub Refactor Spaces environment. The caller owns the environment resource, and all Refactor Spaces applications, services, and routes created within the environment. They are referred to as the environment owner. The environment owner has cross-account visibility and control of Refactor Spaces resources that are added to the environment by other accounts that the environment is shared with.

When creating an environment with a CreateEnvironment:NetworkFabricType of TRANSIT_GATEWAY, Refactor Spaces provisions a transit gateway to enable services in VPCs to communicate directly across accounts. If CreateEnvironment:NetworkFabricType is NONE, Refactor Spaces does not create a transit gateway and you must use your network infrastructure to route traffic to services with private URL endpoints.

Parameters:

  • name (EnvironmentName) –

    The name of the environment.

  • description (Optional[Description], default: None ) –

    The description of the environment.

  • network_fabric_type (NetworkFabricType) –

    The network fabric type of the environment.

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

    The tags to assign to the environment. 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_environment(
    self,
    name: "capo_migration_hub_refactor_spaces.types.environment_name.EnvironmentName",
    network_fabric_type: "capo_migration_hub_refactor_spaces.types.network_fabric_type.NetworkFabricType",
    *,
    config_overrides: Optional[AsyncMigrationHubRefactorSpacesClientConfig] = None,
    description: Optional[
        "capo_migration_hub_refactor_spaces.types.description.Description"
    ] = 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_environment_response.CreateEnvironmentResponse":
    """<p>Creates an Amazon Web Services Migration Hub Refactor Spaces environment. The caller owns the environment resource, and all Refactor Spaces applications, services, and routes created within the environment. They are referred to as the <i>environment owner</i>. The environment owner has cross-account visibility and control of Refactor Spaces resources that are added to the environment by other accounts that the environment is shared with.</p> <p>When creating an environment with a <a href="https://docs.aws.amazon.com/migrationhub-refactor-spaces/latest/APIReference/API_CreateEnvironment.html#migrationhubrefactorspaces-CreateEnvironment-request-NetworkFabricType">CreateEnvironment:NetworkFabricType</a> of <code>TRANSIT_GATEWAY</code>, Refactor Spaces provisions a transit gateway to enable services in VPCs to communicate directly across accounts. If <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>, Refactor Spaces does not create a transit gateway and you must use your network infrastructure to route traffic to services with private URL endpoints.</p>

    Args:
        name: <p>The name of the environment.</p>
        description: <p>The description of the environment.</p>
        network_fabric_type: <p>The network fabric type of the environment.</p>
        tags: <p>The tags to assign to the environment. 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_environment_request.CreateEnvironmentRequest]",
    ) -> AsyncOperationResponse[
        "capo_migration_hub_refactor_spaces.types.create_environment_response.CreateEnvironmentResponse"
    ]:
        import capo_migration_hub_refactor_spaces._operations.refactor_spaces.create_environment

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

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

        return capo_migration_hub_refactor_spaces.types.create_environment_request.redact_sensitive(
            input_
        )

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

        return capo_migration_hub_refactor_spaces.types.create_environment_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateEnvironment",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_migration_hub_refactor_spaces.types.create_environment_request.CreateEnvironmentRequest = {
        "name": name,
        "network_fabric_type": network_fabric_type,
    }
    if description is not None:
        input_["description"] = description
    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