Skip to content

create_cluster

create_cluster(
    cluster_name: ClusterName,
    scheduler: SchedulerRequest,
    size: Size,
    networking: NetworkingRequest,
    *,
    config_overrides: Optional[PCSClientConfig] = None,
    slurm_configuration: Optional[ClusterSlurmConfigurationRequest] = None,
    client_token: Optional[SBClientToken] = None,
    tags: Optional[RequestTagMap] = None,
) -> CreateClusterResponse

Creates a cluster in your account. PCS creates the cluster controller in a service-owned account. The cluster controller communicates with the cluster resources in your account. The subnets and security groups for the cluster must already exist before you use this API action.

It takes time for PCS to create the cluster. The cluster is in a Creating state until it is ready to use. There can only be 1 cluster in a Creating state per Amazon Web Services Region per Amazon Web Services account. CreateCluster fails with a ServiceQuotaExceededException if there is already a cluster in a Creating state.

Parameters:

  • cluster_name (ClusterName) –

    A name to identify the cluster. Example: MyCluster

  • scheduler (SchedulerRequest) –

    The cluster management and job scheduling software associated with the cluster.

  • size (Size) –

    A value that determines the maximum number of compute nodes in the cluster and the maximum number of jobs (active and queued).

    • SMALL: 32 compute nodes and 256 jobs

    • MEDIUM: 512 compute nodes and 8192 jobs

    • LARGE: 2048 compute nodes and 16,384 jobs

  • networking (NetworkingRequest) –

    The networking configuration used to set up the cluster's control plane.

  • slurm_configuration (Optional[ClusterSlurmConfigurationRequest], default: None ) –

    Additional options related to the Slurm scheduler.

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

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Idempotency ensures that an API request completes only once. With an idempotent request, if the original request completes successfully, the subsequent retries with the same client token return the result from the original successful request and they have no additional effect. If you don't specify a client token, the CLI and SDK automatically generate 1 for you.

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

    1 or more tags added to the resource. Each tag consists of a tag key and tag value. The tag value is optional and can be an empty string.

Raises:

  • AccessDeniedException –

    You don't have permission to perform the action.

    Examples

    • The launch template instance profile doesn't pass iam:PassRole verification.

    • There is a mismatch between the account ID and cluster ID.

    • The cluster ID doesn't exist.

    • The EC2 instance isn't present.

  • ConflictException –

    Your request has conflicting operations. This can occur if you're trying to perform more than 1 operation on the same resource at the same time.

    Examples

    • A cluster with the same name already exists.

    • A cluster isn't in ACTIVE status.

    • A cluster to delete is in an unstable state. For example, because it still has ACTIVE node groups or queues.

    • A queue already exists in a cluster.

  • InternalServerException –

    PCS can't process your request right now. Try again later.

  • ServiceQuotaExceededException –

    You exceeded your service quota. Service quotas, also referred to as limits, are the maximum number of service resources or operations for your Amazon Web Services account. To learn how to increase your service quota, see Requesting a quota increase in the Service Quotas User Guide

    Examples

    • The max number of clusters or queues has been reached for the account.

    • The max number of compute node groups has been reached for the associated cluster.

    • The total of maxInstances across all compute node groups has been reached for associated cluster.

  • ThrottlingException –

    Your request exceeded a request rate quota. Check the resource's request rate quota and try again.

  • ValidationException –

    The request isn't valid.

    Examples

    • Your request contains malformed JSON or unsupported characters.

    • The scheduler version isn't supported.

    • There are networking related errors, such as network validation failure.

    • AMI type is CUSTOM and the launch template doesn't define the AMI ID, or the AMI type is AL2 and the launch template defines the AMI.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_pcs/_services/pcs.py
def create_cluster(
    self,
    cluster_name: "capo_pcs.types.cluster_name.ClusterName",
    scheduler: "capo_pcs.types.scheduler_request.SchedulerRequest",
    size: "capo_pcs.types.size.Size",
    networking: "capo_pcs.types.networking_request.NetworkingRequest",
    *,
    config_overrides: Optional[PCSClientConfig] = None,
    slurm_configuration: Optional[
        "capo_pcs.types.cluster_slurm_configuration_request.ClusterSlurmConfigurationRequest"
    ] = None,
    client_token: Optional["capo_pcs.types.sb_client_token.SBClientToken"] = None,
    tags: Optional["capo_pcs.types.request_tag_map.RequestTagMap"] = None,
) -> "capo_pcs.types.create_cluster_response.CreateClusterResponse":
    """<p>Creates a cluster in your account. PCS creates the cluster controller in a service-owned account. The cluster controller communicates with the cluster resources in your account. The subnets and security groups for the cluster must already exist before you use this API action.</p> <note> <p>It takes time for PCS to create the cluster. The cluster is in a <code>Creating</code> state until it is ready to use. There can only be 1 cluster in a <code>Creating</code> state per Amazon Web Services Region per Amazon Web Services account. <code>CreateCluster</code> fails with a <code>ServiceQuotaExceededException</code> if there is already a cluster in a <code>Creating</code> state.</p> </note>

    Args:
        cluster_name: <p>A name to identify the cluster. Example: <code>MyCluster</code> </p>
        scheduler: <p>The cluster management and job scheduling software associated with the cluster.</p>
        size: <p>A value that determines the maximum number of compute nodes in the cluster and the maximum number of jobs (active and queued).</p> <ul> <li> <p> <code>SMALL</code>: 32 compute nodes and 256 jobs</p> </li> <li> <p> <code>MEDIUM</code>: 512 compute nodes and 8192 jobs</p> </li> <li> <p> <code>LARGE</code>: 2048 compute nodes and 16,384 jobs</p> </li> </ul>
        networking: <p>The networking configuration used to set up the cluster's control plane.</p>
        slurm_configuration: <p>Additional options related to the Slurm scheduler.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Idempotency ensures that an API request completes only once. With an idempotent request, if the original request completes successfully, the subsequent retries with the same client token return the result from the original successful request and they have no additional effect. If you don't specify a client token, the CLI and SDK automatically generate 1 for you.</p>
        tags: <p>1 or more tags added to the resource. Each tag consists of a tag key and tag value. The tag value is optional and can be an empty string.</p>

    Raises:
        capo_pcs.errors.access_denied_exception.AccessDeniedException: <p>You don't have permission to perform the action.</p> <p> <u>Examples</u> </p> <ul> <li> <p>The launch template instance profile doesn't pass <code>iam:PassRole</code> verification.</p> </li> <li> <p>There is a mismatch between the account ID and cluster ID.</p> </li> <li> <p>The cluster ID doesn't exist.</p> </li> <li> <p>The EC2 instance isn't present.</p> </li> </ul>
        capo_pcs.errors.conflict_exception.ConflictException: <p>Your request has conflicting operations. This can occur if you're trying to perform more than 1 operation on the same resource at the same time.</p> <p> <u>Examples</u> </p> <ul> <li> <p>A cluster with the same name already exists.</p> </li> <li> <p>A cluster isn't in <code>ACTIVE</code> status.</p> </li> <li> <p>A cluster to delete is in an unstable state. For example, because it still has <code>ACTIVE</code> node groups or queues.</p> </li> <li> <p>A queue already exists in a cluster.</p> </li> </ul>
        capo_pcs.errors.internal_server_exception.InternalServerException: <p>PCS can't process your request right now. Try again later.</p>
        capo_pcs.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You exceeded your service quota. Service quotas, also referred to as limits, are the maximum number of service resources or operations for your Amazon Web Services account. To learn how to increase your service quota, see <a href="https://docs.aws.amazon.com/servicequotas/latest/userguide/request-quota-increase.html">Requesting a quota increase</a> in the <i>Service Quotas User Guide</i> </p> <p> <u>Examples</u> </p> <ul> <li> <p>The max number of clusters or queues has been reached for the account.</p> </li> <li> <p>The max number of compute node groups has been reached for the associated cluster.</p> </li> <li> <p>The total of <code>maxInstances</code> across all compute node groups has been reached for associated cluster.</p> </li> </ul>
        capo_pcs.errors.throttling_exception.ThrottlingException: <p>Your request exceeded a request rate quota. Check the resource's request rate quota and try again.</p>
        capo_pcs.errors.validation_exception.ValidationException: <p>The request isn't valid.</p> <p> <u>Examples</u> </p> <ul> <li> <p>Your request contains malformed JSON or unsupported characters.</p> </li> <li> <p>The scheduler version isn't supported.</p> </li> <li> <p>There are networking related errors, such as network validation failure.</p> </li> <li> <p>AMI type is <code>CUSTOM</code> and the launch template doesn't define the AMI ID, or the AMI type is AL2 and the launch template defines the AMI.</p> </li> </ul>
        capo_pcs.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_pcs.types.create_cluster_request.CreateClusterRequest]",
    ) -> OperationResponse[
        "capo_pcs.types.create_cluster_response.CreateClusterResponse"
    ]:
        import capo_pcs._operations.aws_parallel_computing_service.create_cluster

        output, http_response = (
            capo_pcs._operations.aws_parallel_computing_service.create_cluster.create_cluster(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateCluster")
    )
    input_: capo_pcs.types.create_cluster_request.CreateClusterRequest = {
        "cluster_name": cluster_name,
        "scheduler": scheduler,
        "size": size,
        "networking": networking,
    }
    if slurm_configuration is not None:
        input_["slurm_configuration"] = slurm_configuration
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output