Skip to content

update_compute_node_group

update_compute_node_group(
    cluster_identifier: ClusterIdentifier,
    compute_node_group_identifier: ComputeNodeGroupIdentifier,
    *,
    config_overrides: Optional[PCSClientConfig] = None,
    ami_id: Optional[AmiId] = None,
    subnet_ids: Optional[StringList] = None,
    custom_launch_template: Optional[CustomLaunchTemplate] = None,
    purchase_option: Optional[PurchaseOption] = None,
    spot_options: Optional[SpotOptions] = None,
    scaling_configuration: Optional[ScalingConfigurationRequest] = None,
    iam_instance_profile_arn: Optional[InstanceProfileArn] = None,
    slurm_configuration: Optional[
        UpdateComputeNodeGroupSlurmConfigurationRequest
    ] = None,
    node_lifecycle_actions: Optional[UpdateNodeLifecycleActionsRequest] = None,
    client_token: Optional[SBClientToken] = None,
) -> UpdateComputeNodeGroupResponse

Updates a compute node group. You can update many of the fields related to your compute node group including the configurations for networking, compute nodes, and settings specific to your scheduler (such as Slurm).

Parameters:

  • cluster_identifier (ClusterIdentifier) –

    The name or ID of the cluster of the compute node group.

  • compute_node_group_identifier (ComputeNodeGroupIdentifier) –

    The name or ID of the compute node group.

  • ami_id (Optional[AmiId], default: None ) –

    The ID of the Amazon Machine Image (AMI) that PCS uses to launch instances. If not provided, PCS uses the AMI ID specified in the custom launch template.

  • subnet_ids (Optional[StringList], default: None ) –

    The list of subnet IDs where the compute node group provisions instances. The subnets must be in the same VPC as the cluster.

  • purchase_option (Optional[PurchaseOption], default: None ) –

    Specifies how EC2 instances are purchased on your behalf. PCS supports On-Demand Instances, Spot Instances, Interruptible Capacity Reservations, On-Demand Capacity Reservations, and Amazon EC2 Capacity Blocks for ML. For more information, see Amazon EC2 billing and purchasing options in the Amazon Elastic Compute Cloud User Guide. For more information about PCS support for Capacity Blocks, see Using Amazon EC2 Capacity Blocks for ML with PCS in the PCS User Guide. For more information about PCS support for interruptible capacity reservations, see Using I-ODCRs with PCS in the PCS User Guide. Choose On-Demand if you plan to use an On-Demand Capacity Reservation (ODCR). For more information, see Using ODCRs with PCS. If you don't provide this option, it defaults to On-Demand.

  • scaling_configuration (Optional[ScalingConfigurationRequest], default: None ) –

    Specifies the boundaries of the compute node group auto scaling.

  • iam_instance_profile_arn (Optional[InstanceProfileArn], default: None ) –

    The Amazon Resource Name (ARN) of the IAM instance profile used to pass an IAM role when launching EC2 instances. The role contained in your instance profile must have the pcs:RegisterComputeNodeGroupInstance permission and the role name must start with AWSPCS or must have the path /aws-pcs/. For more information, see IAM instance profiles for PCS in the PCS User Guide.

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

    Additional options related to the Slurm scheduler.

  • node_lifecycle_actions (Optional[UpdateNodeLifecycleActionsRequest], default: None ) –

    The lifecycle actions to run on compute nodes in the compute node group. Use lifecycle actions to run custom scripts at defined stages of a compute node's lifecycle, such as when a compute node finishes bootstrapping or becomes ready to accept jobs.

  • 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.

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.

  • ResourceNotFoundException –

    The requested resource can't be found. The cluster, node group, or queue you're attempting to get, update, list, or delete doesn't exist.

    Examples

  • 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 update_compute_node_group(
    self,
    cluster_identifier: "capo_pcs.types.cluster_identifier.ClusterIdentifier",
    compute_node_group_identifier: "capo_pcs.types.compute_node_group_identifier.ComputeNodeGroupIdentifier",
    *,
    config_overrides: Optional[PCSClientConfig] = None,
    ami_id: Optional["capo_pcs.types.ami_id.AmiId"] = None,
    subnet_ids: Optional["capo_pcs.types.string_list.StringList"] = None,
    custom_launch_template: Optional[
        "capo_pcs.types.custom_launch_template.CustomLaunchTemplate"
    ] = None,
    purchase_option: Optional[
        "capo_pcs.types.purchase_option.PurchaseOption"
    ] = None,
    spot_options: Optional["capo_pcs.types.spot_options.SpotOptions"] = None,
    scaling_configuration: Optional[
        "capo_pcs.types.scaling_configuration_request.ScalingConfigurationRequest"
    ] = None,
    iam_instance_profile_arn: Optional[
        "capo_pcs.types.instance_profile_arn.InstanceProfileArn"
    ] = None,
    slurm_configuration: Optional[
        "capo_pcs.types.update_compute_node_group_slurm_configuration_request.UpdateComputeNodeGroupSlurmConfigurationRequest"
    ] = None,
    node_lifecycle_actions: Optional[
        "capo_pcs.types.update_node_lifecycle_actions_request.UpdateNodeLifecycleActionsRequest"
    ] = None,
    client_token: Optional["capo_pcs.types.sb_client_token.SBClientToken"] = None,
) -> "capo_pcs.types.update_compute_node_group_response.UpdateComputeNodeGroupResponse":
    """<p>Updates a compute node group. You can update many of the fields related to your compute node group including the configurations for networking, compute nodes, and settings specific to your scheduler (such as Slurm).</p>

    Args:
        cluster_identifier: <p>The name or ID of the cluster of the compute node group.</p>
        compute_node_group_identifier: <p>The name or ID of the compute node group.</p>
        ami_id: <p>The ID of the Amazon Machine Image (AMI) that PCS uses to launch instances. If not provided, PCS uses the AMI ID specified in the custom launch template.</p>
        subnet_ids: <p>The list of subnet IDs where the compute node group provisions instances. The subnets must be in the same VPC as the cluster.</p>
        purchase_option: <p>Specifies how EC2 instances are purchased on your behalf. PCS supports On-Demand Instances, Spot Instances, Interruptible Capacity Reservations, On-Demand Capacity Reservations, and Amazon EC2 Capacity Blocks for ML. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-purchasing-options.html">Amazon EC2 billing and purchasing options</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>. For more information about PCS support for Capacity Blocks, see <a href="https://docs.aws.amazon.com/pcs/latest/userguide/capacity-blocks.html">Using Amazon EC2 Capacity Blocks for ML with PCS</a> in the <i>PCS User Guide</i>. For more information about PCS support for interruptible capacity reservations, see <a href="https://docs.aws.amazon.com/pcs/latest/userguide/capacity-reservations-iodcr.html">Using I-ODCRs with PCS</a> in the <i>PCS User Guide</i>. Choose On-Demand if you plan to use an On-Demand Capacity Reservation (ODCR). For more information, see <a href="https://docs.aws.amazon.com/pcs/latest/userguide/capacity-reservations-odcr.html">Using ODCRs with PCS</a>. If you don't provide this option, it defaults to On-Demand.</p>
        scaling_configuration: <p>Specifies the boundaries of the compute node group auto scaling.</p>
        iam_instance_profile_arn: <p>The Amazon Resource Name (ARN) of the IAM instance profile used to pass an IAM role when launching EC2 instances. The role contained in your instance profile must have the <code>pcs:RegisterComputeNodeGroupInstance</code> permission and the role name must start with <code>AWSPCS</code> or must have the path <code>/aws-pcs/</code>. For more information, see <a href="https://docs.aws.amazon.com/pcs/latest/userguide/security-instance-profiles.html">IAM instance profiles for PCS</a> in the <i>PCS User Guide</i>.</p>
        slurm_configuration: <p>Additional options related to the Slurm scheduler.</p>
        node_lifecycle_actions: <p>The lifecycle actions to run on compute nodes in the compute node group. Use lifecycle actions to run custom scripts at defined stages of a compute node's lifecycle, such as when a compute node finishes bootstrapping or becomes ready to accept jobs.</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>

    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.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource can't be found. The cluster, node group, or queue you're attempting to get, update, list, or delete doesn't exist.</p> <p> <u>Examples</u> </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.update_compute_node_group_request.UpdateComputeNodeGroupRequest]",
    ) -> OperationResponse[
        "capo_pcs.types.update_compute_node_group_response.UpdateComputeNodeGroupResponse"
    ]:
        import capo_pcs._operations.aws_parallel_computing_service.update_compute_node_group

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateComputeNodeGroup")
    )
    input_: capo_pcs.types.update_compute_node_group_request.UpdateComputeNodeGroupRequest = {
        "cluster_identifier": cluster_identifier,
        "compute_node_group_identifier": compute_node_group_identifier,
    }
    if ami_id is not None:
        input_["ami_id"] = ami_id
    if subnet_ids is not None:
        input_["subnet_ids"] = subnet_ids
    if custom_launch_template is not None:
        input_["custom_launch_template"] = custom_launch_template
    if purchase_option is not None:
        input_["purchase_option"] = purchase_option
    if spot_options is not None:
        input_["spot_options"] = spot_options
    if scaling_configuration is not None:
        input_["scaling_configuration"] = scaling_configuration
    if iam_instance_profile_arn is not None:
        input_["iam_instance_profile_arn"] = iam_instance_profile_arn
    if slurm_configuration is not None:
        input_["slurm_configuration"] = slurm_configuration
    if node_lifecycle_actions is not None:
        input_["node_lifecycle_actions"] = node_lifecycle_actions
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

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