Class CustomModel


  • public class CustomModel
    extends com.pulumi.resources.CustomResource
    Manages an Amazon Bedrock custom model. Model customization is the process of providing training data to a base model in order to improve its performance for specific use-cases. This Terraform resource interacts with two Amazon Bedrock entities: 1. A Continued Pre-training or Fine-tuning job which is started when the Terraform resource is created. The customization job can take several hours to run to completion. The duration of the job depends on the size of the training data (number of records, input tokens, and output tokens), and [hyperparameters](https://docs.aws.amazon.com/bedrock/latest/userguide/custom-models-hp.html) (number of epochs, and batch size). 2. The custom model output on successful completion of the customization job. This resource's behaviors correspond to operations on these Amazon Bedrock entities: * _Create_ starts the customization job and immediately returns. * _Read_ returns the status and results of the customization job. If the customization job has completed, the output model's properties are returned. * _Update_ updates the customization job's [tags](https://docs.aws.amazon.com/bedrock/latest/userguide/tagging.html). * _Delete_ stops the customization job if it is still active. If the customization job has completed, the custom model output by the job is deleted. ## Example Usage
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.bedrockfoundation.BedrockfoundationFunctions;
     import com.pulumi.aws.bedrockfoundation.inputs.GetModelArgs;
     import com.pulumi.aws.bedrock.CustomModel;
     import com.pulumi.aws.bedrock.CustomModelArgs;
     import com.pulumi.aws.bedrock.inputs.CustomModelOutputDataConfigArgs;
     import com.pulumi.aws.bedrock.inputs.CustomModelTrainingDataConfigArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             final var example = BedrockfoundationFunctions.getModel(GetModelArgs.builder()
                 .modelId("amazon.titan-text-express-v1")
                 .build());
     
             var exampleCustomModel = new CustomModel("exampleCustomModel", CustomModelArgs.builder()
                 .outputDataConfig(CustomModelOutputDataConfigArgs.builder()
                     .s3Uri(String.format("s3://%s/data/", output.id()))
                     .build())
                 .trainingDataConfig(CustomModelTrainingDataConfigArgs.builder()
                     .s3Uri(String.format("s3://%s/data/train.jsonl", training.id()))
                     .build())
                 .customModelName("example-model")
                 .jobName("example-job-1")
                 .baseModelIdentifier(example.modelArn())
                 .roleArn(exampleAwsIamRole.arn())
                 .hyperparameters(Map.ofEntries(
                     Map.entry("epochCount", "1"),
                     Map.entry("batchSize", "1"),
                     Map.entry("learningRate", "0.005"),
                     Map.entry("learningRateWarmupSteps", "0")
                 ))
                 .build());
     
         }
     }
     
     
    ## Import ### Identity Schema #### Required - `jobArn` (String) ARN of the Bedrock custom model job. Using `pulumi import`, import Bedrock custom model using the `jobArn`. For example: ```sh $ pulumi import aws:bedrock/customModel:CustomModel example arn:aws:bedrock:us-west-2:123456789012:model-customization-job/amazon.titan-text-express-v1:0:8k/1y5n57gh5y2e ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Detail

      • CustomModel

        public CustomModel​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • CustomModel

        public CustomModel​(java.lang.String name,
                           CustomModelArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • CustomModel

        public CustomModel​(java.lang.String name,
                           CustomModelArgs args,
                           @Nullable
                           com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • baseModelIdentifier

        public com.pulumi.core.Output<java.lang.String> baseModelIdentifier()
        Returns:
        ARN of the base model.
      • customModelArn

        public com.pulumi.core.Output<java.lang.String> customModelArn()
        Returns:
        ARN of the output model.
      • customModelKmsKeyId

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> customModelKmsKeyId()
        Returns:
        Key ARN used to encrypt the custom model at rest.
      • customModelName

        public com.pulumi.core.Output<java.lang.String> customModelName()
        Returns:
        Name for the custom model.
      • customizationType

        public com.pulumi.core.Output<java.lang.String> customizationType()
        Returns:
        Customization type. Valid values: `FINE_TUNING`, `CONTINUED_PRE_TRAINING`.
      • hyperparameters

        public com.pulumi.core.Output<java.util.Map<java.lang.String,​java.lang.String>> hyperparameters()
        Returns:
        [Parameters](https://docs.aws.amazon.com/bedrock/latest/userguide/custom-models-hp.html) related to tuning the model.
      • jobArn

        public com.pulumi.core.Output<java.lang.String> jobArn()
        Returns:
        ARN of the customization job.
      • jobName

        public com.pulumi.core.Output<java.lang.String> jobName()
        Returns:
        Name for the customization job.
      • jobStatus

        public com.pulumi.core.Output<java.lang.String> jobStatus()
        Returns:
        Status of the customization job. A successful job transitions from `InProgress` to `Completed` when the output model is ready to use.
      • outputDataConfig

        public com.pulumi.core.Output<CustomModelOutputDataConfig> outputDataConfig()
        Returns:
        S3 location for the output data. See `outputDataConfig` below.
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • roleArn

        public com.pulumi.core.Output<java.lang.String> roleArn()
        Returns:
        ARN of an IAM role that Bedrock can assume to perform tasks on your behalf.
      • tags

        public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> tags()
        Returns:
        Map of tags to assign to the customization job and custom model. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
      • tagsAll

        public com.pulumi.core.Output<java.util.Map<java.lang.String,​java.lang.String>> tagsAll()
        Returns:
        Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
      • trainingDataConfig

        public com.pulumi.core.Output<CustomModelTrainingDataConfig> trainingDataConfig()
        Returns:
        Information about the training dataset. See `trainingDataConfig` below.
      • trainingMetrics

        public com.pulumi.core.Output<java.util.List<CustomModelTrainingMetric>> trainingMetrics()
        Returns:
        Metrics associated with the customization job.
      • validationDataConfig

        public com.pulumi.core.Output<java.util.Optional<CustomModelValidationDataConfig>> validationDataConfig()
        Returns:
        Information about the validation dataset. See `validationDataConfig` below.
      • validationMetrics

        public com.pulumi.core.Output<java.util.List<CustomModelValidationMetric>> validationMetrics()
        Returns:
        Loss metric for each validator that you provided.
      • vpcConfig

        public com.pulumi.core.Output<java.util.Optional<CustomModelVpcConfig>> vpcConfig()
        Returns:
        Configuration parameters for the private VPC that contains the resources you are using for this job. See `vpcConfig` below.
      • get

        public static CustomModel get​(java.lang.String name,
                                      com.pulumi.core.Output<java.lang.String> id,
                                      @Nullable
                                      CustomModelState state,
                                      @Nullable
                                      com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.