createComputeNodeGroup method

Future<CreateComputeNodeGroupResponse> createComputeNodeGroup({
  1. required String clusterIdentifier,
  2. required String computeNodeGroupName,
  3. required CustomLaunchTemplate customLaunchTemplate,
  4. required String iamInstanceProfileArn,
  5. required List<InstanceConfig> instanceConfigs,
  6. required ScalingConfigurationRequest scalingConfiguration,
  7. required List<String> subnetIds,
  8. String? amiId,
  9. String? clientToken,
  10. PurchaseOption? purchaseOption,
  11. ComputeNodeGroupSlurmConfigurationRequest? slurmConfiguration,
  12. SpotOptions? spotOptions,
  13. Map<String, String>? tags,
})

Creates a managed set of compute nodes. You associate a compute node group with a cluster through 1 or more PCS queues or as part of the login fleet. A compute node group includes the definition of the compute properties and lifecycle management. 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 PCS launches in your account. You must already have a launch template before you call this API. For more information, see Launch an instance from a launch template in the Amazon Elastic Compute Cloud User Guide for Linux Instances.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

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

Parameter computeNodeGroupName : A name to identify the cluster. Example: MyCluster

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

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

Parameter scalingConfiguration : Specifies the boundaries of the compute node group auto scaling.

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

Parameter amiId : The ID of the Amazon Machine Image (AMI) that PCS uses to launch compute nodes (Amazon EC2 instances). If you don't provide this value, PCS uses the AMI ID specified in the custom launch template.

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

Parameter purchaseOption : 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.

Parameter slurmConfiguration : Additional options related to the Slurm scheduler.

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

Implementation

Future<CreateComputeNodeGroupResponse> createComputeNodeGroup({
  required String clusterIdentifier,
  required String computeNodeGroupName,
  required CustomLaunchTemplate customLaunchTemplate,
  required String iamInstanceProfileArn,
  required List<InstanceConfig> instanceConfigs,
  required ScalingConfigurationRequest scalingConfiguration,
  required List<String> subnetIds,
  String? amiId,
  String? clientToken,
  PurchaseOption? purchaseOption,
  ComputeNodeGroupSlurmConfigurationRequest? slurmConfiguration,
  SpotOptions? spotOptions,
  Map<String, String>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'AWSParallelComputingService.CreateComputeNodeGroup'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'clusterIdentifier': clusterIdentifier,
      'computeNodeGroupName': computeNodeGroupName,
      'customLaunchTemplate': customLaunchTemplate,
      'iamInstanceProfileArn': iamInstanceProfileArn,
      'instanceConfigs': instanceConfigs,
      'scalingConfiguration': scalingConfiguration,
      'subnetIds': subnetIds,
      if (amiId != null) 'amiId': amiId,
      'clientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (purchaseOption != null) 'purchaseOption': purchaseOption.value,
      if (slurmConfiguration != null)
        'slurmConfiguration': slurmConfiguration,
      if (spotOptions != null) 'spotOptions': spotOptions,
      if (tags != null) 'tags': tags,
    },
  );

  return CreateComputeNodeGroupResponse.fromJson(jsonResponse.body);
}