Skip to content

update_compute_node_group async

update_compute_node_group(
    cluster_identifier: ClusterIdentifier,
    compute_node_group_identifier: ComputeNodeGroupIdentifier,
    *,
    config_overrides: Optional[AsyncPCSClientConfig] = None,
    ami_id: Optional[AmiIdOrEmpty] = None,
    security_group_ids: Optional[SecurityGroupIdListOrEmpty] = None,
    ssh_key_name: Optional[KeyPairNameOrEmpty] = None,
    subnet_ids: Optional[StringList] = None,
    launch_template_mode: Optional[LaunchTemplateMode] = 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,
    instance_health_checks: Optional[UpdateInstanceHealthChecksRequest] = 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:

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

    The ID of the Amazon Machine Image (AMI) that PCS uses to launch instances. This value overrides the AMI ID in the custom launch template. Specify an empty string ("") to remove the AMI ID from the compute node group and use the AMI ID specified in the custom launch template. Omit this value to leave the current setting unchanged.

  • security_group_ids (Optional[SecurityGroupIdListOrEmpty], default: None ) –

    The IDs of the EC2 security groups to configure directly on the compute node group. The security groups must be in the same VPC as the cluster. PCS uses these security groups instead of the security groups in the custom launch template. You can't specify this value if the custom launch template defines network interfaces. Specify an empty list ([]) to remove the security groups from the compute node group and use the security groups in the custom launch template. Omit this value to leave the current setting unchanged.

  • ssh_key_name (Optional[KeyPairNameOrEmpty], default: None ) –

    The name of the EC2 key pair to configure directly on the compute node group. The key pair must exist in your account and Amazon Web Services Region. PCS uses this key pair instead of the key pair in the custom launch template. Specify an empty string ("") to remove the key pair from the compute node group and use the key pair in the custom launch template. Omit this value to leave the current setting unchanged. You must have permission for ec2:DescribeKeyPairs to specify a key pair. If you delete the key pair later, future instance launches can fail.

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

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

  • launch_template_mode (Optional[LaunchTemplateMode], default: None ) –

    Specifies whether the compute node group uses a custom launch template or a launch template that PCS manages. Omit this value to keep the current mode.

    Valid values:

    • CUSTOM – Use a custom launch template. To switch from MANAGED, also provide customLaunchTemplate. If the compute node group already uses CUSTOM and you omit customLaunchTemplate, the existing launch template is unchanged.

    • MANAGED – Use a launch template created and managed by PCS. Omit customLaunchTemplate. Switching to this mode removes the custom launch template association but doesn't delete the launch template.

    When switching to MANAGED, the compute node group must have amiId and securityGroupIds configured. You can set these values in the same request.

  • custom_launch_template (Optional[CustomLaunchTemplate], default: None ) –

    The custom Amazon EC2 launch template to associate with the compute node group. To set or change the custom launch template, specify id and version. If you provide this value and omit launchTemplateMode, the compute node group must already use CUSTOM mode. To switch from MANAGED to CUSTOM, specify launchTemplateMode as CUSTOM and provide this value. If the compute node group already uses CUSTOM, omit this value while also omitting launchTemplateMode, or while specifying CUSTOM, to keep the existing custom launch template. For more information, see Migrating a compute node group from a custom launch template in the PCS User Guide.

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

  • instance_health_checks (Optional[UpdateInstanceHealthChecksRequest], default: None ) –

    The instance health check settings for the compute node group. Instance health checks detect faults on instances in the compute node group and respond with the repair action that you choose. You can configure health monitoring, deep health checks, or both. You can't specify an empty object ({}). Instance health checks require Slurm version 26.05 or later.

    The settings that you specify replace all of the current instance health check settings of the compute node group. Include every setting that you want to keep. If you omit this member, the current settings don't change. If you omit healthMonitoring or deepHealthChecks, that check is turned off. You can also turn off a check: set healthMonitoring.mode or deepHealthChecks.onStart.profile to NONE and omit its repairAction. When you change these settings, PCS drains and replaces the instances in the compute node group.

  • 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 one 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/async_pcs.py
async 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[AsyncPCSClientConfig] = None,
    ami_id: Optional["capo_pcs.types.ami_id_or_empty.AmiIdOrEmpty"] = None,
    security_group_ids: Optional[
        "capo_pcs.types.security_group_id_list_or_empty.SecurityGroupIdListOrEmpty"
    ] = None,
    ssh_key_name: Optional[
        "capo_pcs.types.key_pair_name_or_empty.KeyPairNameOrEmpty"
    ] = None,
    subnet_ids: Optional["capo_pcs.types.string_list.StringList"] = None,
    launch_template_mode: Optional[
        "capo_pcs.types.launch_template_mode.LaunchTemplateMode"
    ] = 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,
    instance_health_checks: Optional[
        "capo_pcs.types.update_instance_health_checks_request.UpdateInstanceHealthChecksRequest"
    ] = 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:
        ami_id: <p>The ID of the Amazon Machine Image (AMI) that PCS uses to launch instances. This value overrides the AMI ID in the custom launch template. Specify an empty string (<code>""</code>) to remove the AMI ID from the compute node group and use the AMI ID specified in the custom launch template. Omit this value to leave the current setting unchanged.</p>
        security_group_ids: <p>The IDs of the EC2 security groups to configure directly on the compute node group. The security groups must be in the same VPC as the cluster. PCS uses these security groups instead of the security groups in the custom launch template. You can't specify this value if the custom launch template defines network interfaces. Specify an empty list (<code>[]</code>) to remove the security groups from the compute node group and use the security groups in the custom launch template. Omit this value to leave the current setting unchanged.</p>
        ssh_key_name: <p>The name of the EC2 key pair to configure directly on the compute node group. The key pair must exist in your account and Amazon Web Services Region. PCS uses this key pair instead of the key pair in the custom launch template. Specify an empty string (<code>""</code>) to remove the key pair from the compute node group and use the key pair in the custom launch template. Omit this value to leave the current setting unchanged. You must have permission for <code>ec2:DescribeKeyPairs</code> to specify a key pair. If you delete the key pair later, future instance launches can fail.</p>
        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>
        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>
        launch_template_mode: <p>Specifies whether the compute node group uses a custom launch template or a launch template that PCS manages. Omit this value to keep the current mode.</p> <p>Valid values:</p> <ul> <li> <p> <code>CUSTOM</code> – Use a custom launch template. To switch from <code>MANAGED</code>, also provide <code>customLaunchTemplate</code>. If the compute node group already uses <code>CUSTOM</code> and you omit <code>customLaunchTemplate</code>, the existing launch template is unchanged.</p> </li> <li> <p> <code>MANAGED</code> – Use a launch template created and managed by PCS. Omit <code>customLaunchTemplate</code>. Switching to this mode removes the custom launch template association but doesn't delete the launch template.</p> </li> </ul> <p>When switching to <code>MANAGED</code>, the compute node group must have <code>amiId</code> and <code>securityGroupIds</code> configured. You can set these values in the same request.</p>
        custom_launch_template: <p>The custom Amazon EC2 launch template to associate with the compute node group. To set or change the custom launch template, specify <code>id</code> and <code>version</code>. If you provide this value and omit <code>launchTemplateMode</code>, the compute node group must already use <code>CUSTOM</code> mode. To switch from <code>MANAGED</code> to <code>CUSTOM</code>, specify <code>launchTemplateMode</code> as <code>CUSTOM</code> and provide this value. If the compute node group already uses <code>CUSTOM</code>, omit this value while also omitting <code>launchTemplateMode</code>, or while specifying <code>CUSTOM</code>, to keep the existing custom launch template. For more information, see <a href="https://docs.aws.amazon.com/pcs/latest/userguide/working-with_cng_instance-settings-migrate.html">Migrating a compute node group from a custom launch template</a> in the <i>PCS User Guide</i>.</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>
        instance_health_checks: <p>The instance health check settings for the compute node group. Instance health checks detect faults on instances in the compute node group and respond with the repair action that you choose. You can configure health monitoring, deep health checks, or both. You can't specify an empty object (<code>{}</code>). Instance health checks require Slurm version 26.05 or later.</p> <p>The settings that you specify replace all of the current instance health check settings of the compute node group. Include every setting that you want to keep. If you omit this member, the current settings don't change. If you omit <code>healthMonitoring</code> or <code>deepHealthChecks</code>, that check is turned off. You can also turn off a check: set <code>healthMonitoring.mode</code> or <code>deepHealthChecks.onStart.profile</code> to <code>NONE</code> and omit its <code>repairAction</code>. When you change these settings, PCS drains and replaces the instances in the compute node group.</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 one 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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_pcs.types.update_compute_node_group_request.UpdateComputeNodeGroupRequest]",
    ) -> AsyncOperationResponse[
        "capo_pcs.types.update_compute_node_group_response.UpdateComputeNodeGroupResponse"
    ]:
        import capo_pcs._operations.aws_parallel_computing_service.update_compute_node_group

        (
            output,
            http_response,
        ) = await capo_pcs._operations.aws_parallel_computing_service.update_compute_node_group.async_update_compute_node_group(
            req.options, req.input
        )
        return AsyncOperationResponse(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 security_group_ids is not None:
        input_["security_group_ids"] = security_group_ids
    if ssh_key_name is not None:
        input_["ssh_key_name"] = ssh_key_name
    if subnet_ids is not None:
        input_["subnet_ids"] = subnet_ids
    if launch_template_mode is not None:
        input_["launch_template_mode"] = launch_template_mode
    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 instance_health_checks is not None:
        input_["instance_health_checks"] = instance_health_checks
    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