# ResourceConfig

Specifies the resources, ML compute instances, and ML storage volumes to deploy for model training.

- Source: [`aws-stepfunctions-tasks/lib/sagemaker/base-types.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/sagemaker/base-types.ts#L198)

## Example

```ts
new tasks.SageMakerCreateTrainingJob(this, 'TrainSagemaker', {
  trainingJobName: sfn.JsonPath.stringAt('$.JobName'),
  algorithmSpecification: {
    algorithmName: 'BlazingText',
    trainingInputMode: tasks.InputMode.FILE,
  },
  inputDataConfig: [{
    channelName: 'train',
    dataSource: {
      s3DataSource: {
        s3DataType: tasks.S3DataType.S3_PREFIX,
        s3Location: tasks.S3Location.fromJsonExpression('$.S3Bucket'),
      },
    },
  }],
  outputDataConfig: {
    s3OutputLocation: tasks.S3Location.fromBucket(s3.Bucket.fromBucketName(this, 'Bucket', 'amzn-s3-demo-bucket'), 'myoutputpath'),
  },
  resourceConfig: {
    instanceCount: 1,
    instanceType: new ec2.InstanceType(sfn.JsonPath.stringAt('$.InstanceType')),
    volumeSize: Size.gibibytes(50),
  }, // optional: default is 1 instance of EC2 `M4.XLarge` with `10GB` volume
  stoppingCondition: {
    maxRuntime: Duration.hours(2),
  }, // optional: default is 1 hour
});
```

## Properties

- `instanceCount`: number (required) — The number of ML compute instances to use.

  **Default:** 1 instance.

- `instanceType`: [InstanceType](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.InstanceType.html) (required) — ML compute instance type.

  **Default:** ec2.InstanceType(ec2.InstanceClass.M4, ec2.InstanceType.XLARGE)

  To provide an instance type from the task input, supply an instance type in the following way
  where the value in the task input is an EC2 instance type prepended with "ml.":

  ```ts
  new ec2.InstanceType(sfn.JsonPath.stringAt('$.path.to.instanceType'));
  ```

- `volumeEncryptionKey`: [IKey](/cdk/api/v2/docs/aws-cdk-lib.aws_kms.IKey.html) — KMS key that Amazon SageMaker uses to encrypt data on the storage volume attached to the ML compute instance(s) that run the training job.

  **Default:** Amazon SageMaker uses the default KMS key for Amazon S3 for your role's account

- `volumeSize`: [Size](/cdk/api/v2/docs/aws-cdk-lib.Size.html) (required) — Size of the ML storage volume that you want to provision.

  **Default:** 10 GB EBS volume.
