Skip to content

create_service async

create_service(
    name: ServiceName,
    environment_identifier: EnvironmentId,
    application_identifier: ApplicationId,
    endpoint_type: ServiceEndpointType,
    *,
    config_overrides: Optional[AsyncMigrationHubRefactorSpacesClientConfig] = None,
    description: Optional[Description] = None,
    vpc_id: Optional[VpcId] = None,
    url_endpoint: Optional[UrlEndpointInput] = None,
    lambda_endpoint: Optional[LambdaEndpointInput] = None,
    tags: Optional[TagMap] = None,
    client_token: Optional[ClientToken] = None,
) -> CreateServiceResponse

Creates an Amazon Web Services Migration Hub Refactor Spaces service. The account owner of the service is always the environment owner, regardless of which account in the environment creates the service. Services have either a URL endpoint in a virtual private cloud (VPC), or a Lambda function endpoint.

If an Amazon Web Services resource is launched in a service VPC, and you want it to be accessible to all of an environment’s services with VPCs and routes, apply the RefactorSpacesSecurityGroup to the resource. Alternatively, to add more cross-account constraints, apply your own security group.

Parameters:

  • name (ServiceName) –

    The name of the service.

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

    The description of the service.

  • environment_identifier (EnvironmentId) –

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

  • application_identifier (ApplicationId) –

    The ID of the application which the service is created.

  • vpc_id (Optional[VpcId], default: None ) –

    The ID of the VPC.

  • endpoint_type (ServiceEndpointType) –

    The type of endpoint to use for the service. The type can be a URL in a VPC or an Lambda function.

  • url_endpoint (Optional[UrlEndpointInput], default: None ) –

    The configuration for the URL endpoint type. When creating a route to a service, Refactor Spaces automatically resolves the address in the UrlEndpointInput object URL when the Domain Name System (DNS) time-to-live (TTL) expires, or every 60 seconds for TTLs less than 60 seconds.

  • lambda_endpoint (Optional[LambdaEndpointInput], default: None ) –

    The configuration for the Lambda endpoint type.

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

    The tags to assign to the service. 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_service(
    self,
    name: "capo_migration_hub_refactor_spaces.types.service_name.ServiceName",
    environment_identifier: "capo_migration_hub_refactor_spaces.types.environment_id.EnvironmentId",
    application_identifier: "capo_migration_hub_refactor_spaces.types.application_id.ApplicationId",
    endpoint_type: "capo_migration_hub_refactor_spaces.types.service_endpoint_type.ServiceEndpointType",
    *,
    config_overrides: Optional[AsyncMigrationHubRefactorSpacesClientConfig] = None,
    description: Optional[
        "capo_migration_hub_refactor_spaces.types.description.Description"
    ] = None,
    vpc_id: Optional[
        "capo_migration_hub_refactor_spaces.types.vpc_id.VpcId"
    ] = None,
    url_endpoint: Optional[
        "capo_migration_hub_refactor_spaces.types.url_endpoint_input.UrlEndpointInput"
    ] = None,
    lambda_endpoint: Optional[
        "capo_migration_hub_refactor_spaces.types.lambda_endpoint_input.LambdaEndpointInput"
    ] = 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_service_response.CreateServiceResponse":
    """<p>Creates an Amazon Web Services Migration Hub Refactor Spaces service. The account owner of the service is always the environment owner, regardless of which account in the environment creates the service. Services have either a URL endpoint in a virtual private cloud (VPC), or a Lambda function endpoint.</p> <important> <p>If an Amazon Web Services resource is launched in a service VPC, and you want it to be accessible to all of an environment’s services with VPCs and routes, apply the <code>RefactorSpacesSecurityGroup</code> to the resource. Alternatively, to add more cross-account constraints, apply your own security group.</p> </important>

    Args:
        name: <p>The name of the service.</p>
        description: <p>The description of the service.</p>
        environment_identifier: <p>The ID of the environment in which the service is created.</p>
        application_identifier: <p>The ID of the application which the service is created.</p>
        vpc_id: <p>The ID of the VPC.</p>
        endpoint_type: <p>The type of endpoint to use for the service. The type can be a URL in a VPC or an Lambda function.</p>
        url_endpoint: <p>The configuration for the URL endpoint type. When creating a route to a service, Refactor Spaces automatically resolves the address in the <code>UrlEndpointInput</code> object URL when the Domain Name System (DNS) time-to-live (TTL) expires, or every 60 seconds for TTLs less than 60 seconds.</p>
        lambda_endpoint: <p>The configuration for the Lambda endpoint type.</p>
        tags: <p>The tags to assign to the service. 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_service_request.CreateServiceRequest]",
    ) -> AsyncOperationResponse[
        "capo_migration_hub_refactor_spaces.types.create_service_response.CreateServiceResponse"
    ]:
        import capo_migration_hub_refactor_spaces._operations.refactor_spaces.create_service

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

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

        return capo_migration_hub_refactor_spaces.types.create_service_request.redact_sensitive(
            input_
        )

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

        return capo_migration_hub_refactor_spaces.types.create_service_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateService",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_migration_hub_refactor_spaces.types.create_service_request.CreateServiceRequest = {
        "name": name,
        "environment_identifier": environment_identifier,
        "application_identifier": application_identifier,
        "endpoint_type": endpoint_type,
    }
    if description is not None:
        input_["description"] = description
    if vpc_id is not None:
        input_["vpc_id"] = vpc_id
    if url_endpoint is not None:
        input_["url_endpoint"] = url_endpoint
    if lambda_endpoint is not None:
        input_["lambda_endpoint"] = lambda_endpoint
    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