hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.64k stars 9.01k forks source link

[Enhancement]: aws_sagemaker_model resource missing ModelAccessConfig #34795

Open akirfman opened 7 months ago

akirfman commented 7 months ago

Terraform Core Version

1.5.7

AWS Provider Version

5.29.0

Affected Resource(s)

resource: aws_sagemaker_model

Expected Behavior

I'm attempting to create an AWS Sagemaker model resource for one of the Meta Llama2 LLMs. I've captured the model data source and needed env vars from a manually created version of the model through SageMaker Jumpstart and converted them into an aws_sagemaker_model resource.

I would expect to be able to successfully create an instance of the model using this resource following the same pattern/configuration that JumpStart used.

Actual Behavior

When I attempt to create the model in my Terraform apply, I'm presented with an error indicating that model creation failed due to the model's EULA not being accepted.

Relevant Error/Panic Output Snippet

│ Error: creating SageMaker model: ValidationException: The AcceptEula value must be explicitly defined as True in order to accept the end-user license agreement (EULA) that this "s3://jumpstart-private-cache-prod-us-east-1/meta-textgeneration/meta-textgeneration-llama-2-13b-f/artifacts/inference-prepack/v1.0.0/" model requires. You are responsible for reviewing and complying with any applicable license terms and making sure they are acceptable for your use case before downloading or using a model.
│   status code: 400, request id: 4873a968-50a9-4aa5-b0b4-8af4cba6ae90
│
│   with module.use1.module.sagemaker_resources.module.models.module.llama2_13b.aws_sagemaker_model.llama2_13b,
│   on modules/sagemaker/models/llama2_13b/main.tf line 18, in resource "aws_sagemaker_model" "llama2_13b":
│   18: resource "aws_sagemaker_model" "llama2_13b" {

Terraform Configuration Files

resource "aws_sagemaker_model" "llama2_13b" {
  name = "meta-textgeneration-llama-2-13b-f-20231130-192251"
  execution_role_arn = var.model_execution_role_arn

  primary_container {
    image = "763104351884.dkr.ecr.us-east-1.amazonaws.com/huggingface-pytorch-tgi-inference:2.0.1-tgi1.1.0-gpu-py39-cu118-ubuntu20.04"
    mode = "SingleModel"
    environment = {
      ENDPOINT_SERVER_TIMEOUT = 3600
      HF_MODEL_ID = "/opt/ml/model"
      MAX_INPUT_LENGTH = 4095
      MAX_TOTAL_TOKENS = 4096
      MODEL_CACHE_ROOT = "/opt/ml/model"
      SAGEMAKER_ENV = 1
      SAGEMAKER_MODEL_SERVER_WORKERS = 1
      SAGEMAKER_PROGRAM = "inference.py"
      SM_NUM_GPUS = 4
      AcceptEula = "True"
      accept_eula = "true"
    }

    model_data_source {
      s3_data_source {
        compression_type = "None"
        s3_data_type     = "S3Prefix"
        s3_uri           = "s3://jumpstart-private-cache-prod-us-east-1/meta-textgeneration/meta-textgeneration-llama-2-13b-f/artifacts/inference-prepack/v1.0.0/"
      }
    }
  }

  enable_network_isolation = true

  tags = local.model_tags
}

Steps to Reproduce

Debug Output

No response

Panic Output

No response

Important Factoids

The AWS API endpoint for creating a SageMaker model possesses an input for ModelAccessConfig under S3DataSource which allows specification of an AcceptEula boolean value:

The documentation for the current (5.29.0 as of creation of this issue) version of the Terraform AWS Provider doesn't indicate support for this input section.

References

AWS Sagemaker Create Model Endpoint Reference:

Would you like to implement a fix?

None

github-actions[bot] commented 7 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

adcontor7 commented 6 months ago

Hello, I have just the same issue when I try to deploy an "aws_sagemaker_model" resource from the s3_data_source: 's3://jumpstart-private-cache-prod-eu-west-1/meta-textgeneration/meta-textgeneration-llama-2-7b-f/artifacts/inference-prepack/v1.0.0/'.

Is there any way to accept EULA programmatically?

justinretzolk commented 6 months ago

Hey @akirfman 👋 Thank you for taking the time to raise this! We consider adding additional functionality to an existing resource to be an enhancement rather than a bug. With that in mind, I've made a couple of adjustments to the issue so that whoever looks into this has a better idea of where to start.

dkhundley commented 5 months ago

@akirfman I find it an amazing coincidence that I stumbled across this issue, while I think we might work for the same employer. 😂 About to send you an email wanting to pick your brain on your work here!

deepakbshetty commented 5 months ago

PR #35873 submitted for review.

caelaintrtas commented 4 months ago

Encountering same issue, wondering when the updates will be pushed?