View a markdown version of this page

CreateComputeNodeGroup - AWS PCS

CreateComputeNodeGroup

Creates a managed set of compute nodes. You associate a compute node group with a cluster through 1 or more AWS PCS queues or as part of the login fleet. A compute node group includes the definition of the compute properties and lifecycle management. AWS PCS uses the information you provide to this API action to launch compute nodes in your account. You can only specify subnets in the same Amazon VPC as your cluster. You receive billing charges for the compute nodes that AWS PCS launches in your account. You can configure common instance settings, such as the AMI, security groups, and SSH key pair, directly on the compute node group, or you can provide a custom EC2 launch template. To use a launch template that AWS PCS manages, set launchTemplateMode to MANAGED and don't provide customLaunchTemplate. In this case, you must specify amiId and securityGroupIds. For more information, see Configuring instance settings for compute node groups in AWS PCS in the AWS PCS User Guide.

Request Syntax

{ "amiId": "string", "clientToken": "string", "clusterIdentifier": "string", "computeNodeGroupName": "string", "customLaunchTemplate": { "id": "string", "version": "string" }, "iamInstanceProfileArn": "string", "instanceConfigs": [ { "instanceType": "string" } ], "launchTemplateMode": "string", "nodeLifecycleActions": { "scriptCachingPolicy": "string", "stages": { "nodeBootstrapped": [ { "arguments": [ "string" ], "executionPolicy": "string", "name": "string", "onError": "string", "scriptSource": { "checksum": "string", "s3VersionId": "string", "scriptLocation": "string" } } ], "nodeReady": [ { "arguments": [ "string" ], "executionPolicy": "string", "name": "string", "onError": "string", "scriptSource": { "checksum": "string", "s3VersionId": "string", "scriptLocation": "string" } } ] } }, "purchaseOption": "string", "scalingConfiguration": { "maxInstanceCount": number, "minInstanceCount": number }, "securityGroupIds": [ "string" ], "slurmConfiguration": { "gresCustomSettings": [ { "string" : "string" } ], "scaleDownIdleTimeInSeconds": number, "slurmCustomSettings": [ { "parameterName": "string", "parameterValue": "string" } ] }, "spotOptions": { "allocationStrategy": "string" }, "sshKeyName": "string", "subnetIds": [ "string" ], "tags": { "string" : "string" } }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

amiId

The ID of the Amazon Machine Image (AMI) that AWS PCS uses to launch compute nodes (Amazon EC2 instances). This value overrides the AMI ID in the custom launch template. If you don't provide this value, AWS PCS uses the AMI ID specified in the custom launch template. You must provide this value if launchTemplateMode is MANAGED.

Type: String

Pattern: ami-[a-z0-9]+

Required: No

clientToken

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 AWS CLI and SDK automatically generate one for you.

Type: String

Length Constraints: Minimum length of 8. Maximum length of 100.

Required: No

clusterIdentifier

The name or ID of the cluster to create a compute node group in.

Type: String

Pattern: (pcs_[a-zA-Z0-9]+|[A-Za-z][A-Za-z0-9-]{2,40})

Required: Yes

computeNodeGroupName

A name to identify the cluster. Example: MyCluster

Type: String

Length Constraints: Minimum length of 3. Maximum length of 25.

Pattern: (?!pcs_)^[A-Za-z][A-Za-z0-9-]+

Required: Yes

customLaunchTemplate

The custom Amazon EC2 launch template to associate with the compute node group. Specify the launch template id and version when launchTemplateMode is CUSTOM. Don't specify this value when launchTemplateMode is MANAGED.

Type: CustomLaunchTemplate object

Required: No

iamInstanceProfileArn

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 AWS PCS in the AWS PCS User Guide.

Type: String

Pattern: arn:aws([a-zA-Z-]{0,10})?:iam::[0-9]{12}:instance-profile/([!-~]{1,510}/)?([\w+=,.@-]{1,128})

Required: Yes

instanceConfigs

A list of EC2 instance configurations that AWS PCS can provision in the compute node group.

Type: Array of InstanceConfig objects

Required: Yes

launchTemplateMode

Specifies whether the compute node group uses a custom launch template or a launch template that AWS PCS manages. The default value is CUSTOM.

If the value is CUSTOM, provide customLaunchTemplate. If the value is MANAGED, omit customLaunchTemplate and provide amiId and securityGroupIds.

Type: String

Valid Values: CUSTOM | MANAGED

Required: No

nodeLifecycleActions

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.

Type: NodeLifecycleActionsRequest object

Required: No

purchaseOption

Specifies how EC2 instances are purchased on your behalf. AWS 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 AWS PCS support for Capacity Blocks, see Using Amazon EC2 Capacity Blocks for ML with AWS PCS in the AWS PCS User Guide. For more information about AWS PCS support for interruptible capacity reservations, see Using I-ODCRs with AWS PCS in the AWS PCS User Guide. Choose On-Demand if you plan to use an On-Demand Capacity Reservation (ODCR). For more information, see Using ODCRs with AWS PCS. If you don't provide this option, it defaults to On-Demand.

Type: String

Valid Values: ONDEMAND | SPOT | CAPACITY_BLOCK | INTERRUPTIBLE_CAPACITY_RESERVATION

Required: No

scalingConfiguration

Specifies the boundaries of the compute node group auto scaling.

Type: ScalingConfigurationRequest object

Required: Yes

securityGroupIds

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. AWS 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. If you don't provide this value, AWS PCS uses the security groups in the custom launch template. You must provide this value if launchTemplateMode is MANAGED. For more information, see Configuring instance settings for compute node groups in AWS PCS in the AWS PCS User Guide.

Type: Array of strings

Pattern: sg-\w{8,17}

Required: No

slurmConfiguration

Additional options related to the Slurm scheduler.

Type: ComputeNodeGroupSlurmConfigurationRequest object

Required: No

spotOptions

Additional configuration when you specify SPOT as the purchaseOption for the CreateComputeNodeGroup API action.

Type: SpotOptions object

Required: No

sshKeyName

The name of the EC2 key pair to configure directly on the compute node group. The key pair must exist in your account and AWS Region. AWS PCS uses this key pair instead of the key pair in the custom launch template. If you don't provide this value, AWS PCS uses the key pair in the custom launch template, if one is specified. You must have permission for ec2:DescribeKeyPairs. If you delete the key pair later, future instance launches can fail. For more information, see Configuring instance settings for compute node groups in AWS PCS in the AWS PCS User Guide.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 255.

Required: No

subnetIds

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

Type: Array of strings

Required: Yes

tags

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.

Type: String to string map

Map Entries: Maximum number of 200 items.

Key Length Constraints: Minimum length of 1. Maximum length of 128.

Value Length Constraints: Minimum length of 0. Maximum length of 256.

Required: No

Response Syntax

{ "computeNodeGroup": { "amiId": "string", "arn": "string", "clusterId": "string", "createdAt": "string", "customLaunchTemplate": { "id": "string", "version": "string" }, "errorInfo": [ { "code": "string", "message": "string" } ], "iamInstanceProfileArn": "string", "id": "string", "instanceConfigs": [ { "instanceType": "string" } ], "launchTemplateMode": "string", "modifiedAt": "string", "name": "string", "nodeLifecycleActions": { "scriptCachingPolicy": "string", "stages": { "nodeBootstrapped": [ { "arguments": [ "string" ], "executionPolicy": "string", "name": "string", "onError": "string", "scriptSource": { "checksum": "string", "s3VersionId": "string", "scriptLocation": "string" } } ], "nodeReady": [ { "arguments": [ "string" ], "executionPolicy": "string", "name": "string", "onError": "string", "scriptSource": { "checksum": "string", "s3VersionId": "string", "scriptLocation": "string" } } ] } }, "purchaseOption": "string", "scalingConfiguration": { "maxInstanceCount": number, "minInstanceCount": number }, "securityGroupIds": [ "string" ], "slurmConfiguration": { "gresCustomSettings": [ { "string" : "string" } ], "scaleDownIdleTimeInSeconds": number, "slurmCustomSettings": [ { "parameterName": "string", "parameterValue": "string" } ] }, "spotOptions": { "allocationStrategy": "string" }, "sshKeyName": "string", "status": "string", "subnetIds": [ "string" ] } }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

computeNodeGroup

A compute node group associated with a cluster.

Type: ComputeNodeGroup object

Errors

For information about the errors that are common to all actions, see Common Error Types.

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.

HTTP Status Code: 400

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.

resourceId

The unique identifier of the resource that caused the conflict exception.

resourceType

The type or category of the resource that caused the conflict exception."

HTTP Status Code: 400

InternalServerException

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

HTTP Status Code: 500

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

resourceId

The unique identifier of the resource that was not found.

resourceType

The type or category of the resource that was not found.

HTTP Status Code: 400

ServiceQuotaExceededException

You exceeded your service quota. Service quotas, also referred to as limits, are the maximum number of service resources or operations for your AWS 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.

quotaCode

The quota code of the service quota that was exceeded.

resourceId

The unique identifier of the resource that caused the quota to be exceeded.

resourceType

The type or category of the resource that caused the quota to be exceeded.

serviceCode

The service code associated with the quota that was exceeded.

HTTP Status Code: 400

ThrottlingException

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

retryAfterSeconds

The number of seconds to wait before retrying the request.

HTTP Status Code: 400

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.

fieldList

A list of fields or properties that failed validation.

reason

The specific reason or cause of the validation error.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: