Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot rename a SageMaker Endpoint Configuration #21811

Closed
izeau opened this issue Nov 17, 2021 · 4 comments · Fixed by #28785
Closed

Cannot rename a SageMaker Endpoint Configuration #21811

izeau opened this issue Nov 17, 2021 · 4 comments · Fixed by #28785
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/sagemaker Issues and PRs that pertain to the sagemaker service.
Milestone

Comments

@izeau
Copy link

izeau commented Nov 17, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

  • Terraform CLI 1.0.11
  • Terraform AWS Provider 3.65.0

Affected Resource(s)

  • aws_sagemaker_endpoint_configuration
  • aws_sagemaker_endpoint

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "aws_sagemaker_model" "model" {
  execution_role_arn = "arn:aws:..."
}

resource "aws_sagemaker_endpoint_configuration" "endpoint_config" {
  name = "endpoint-config"

  production_variants {
    variant_name           = "variant"
    model_name             = aws_sagemaker_model.model.name
    initial_instance_count = 1
    instance_type          = "ml.m5.large"
  }
}

resource "aws_sagemaker_endpoint" "endpoint" {
  name                 = "endpoint"
  endpoint_config_name = aws_sagemaker_endpoint_configuration.endpoint_config.name
}

Debug Output

Hard to obtain atm (running Terraform in a custom CI pipeline), will update if needed

Expected Behavior

Not really sure, name_prefix instead of name would be nice I guess

Actual Behavior

  1. Terraform destroys the old endpoint config
  2. Terraform re-creates a new endpoint config
  3. Terraform tries to update the endpoint
  4. ValidationException: Could not find endpoint configuration "<old_endpoint_config_arn>".

Without specifying a nameedit: nevermind, this seems to be random:

  1. Terraform creates a new endpoint config with a generated name (terraform-${timestamp})
  2. Terraform updates the endpoint
  3. Terraform destroys the old endpoint config

Steps to Reproduce

  1. terraform apply
  2. update the aws_sagemaker_endpoint_configuration.endpoint_config.name attribute
  3. terraform apply

Important Factoids

Nothing really atypical, although the SageMaker docs warns against deleting an endpoint configuration in use by an endpoint:

Note
You must not delete an EndpointConfig in use by an endpoint that is live or while the UpdateEndpoint or CreateEndpoint operations are being performed on the endpoint. To update an endpoint, you must create a new EndpointConfig.

If you delete the EndpointConfig of an endpoint that is active or being created or updated you may lose visibility into the instance type the endpoint is using. The endpoint must be deleted in order to stop incurring charges.

UpdateEndpoint docs

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/sagemaker Issues and PRs that pertain to the sagemaker service. labels Nov 17, 2021
@izeau
Copy link
Author

izeau commented Nov 18, 2021

Found a workaround (kind of) in #14337: in addition to the autogenerated name for the aws_sagemaker_endpoint_configuration resource, we need to set the create_before_destroy lifecycle configuration:

resource "aws_sagemaker_endpoint_configuration" "endpoint_config" {
  name = "endpoint-config"

  production_variants {
    variant_name           = "variant"
    model_name             = aws_sagemaker_model.model.name
    initial_instance_count = 1
    instance_type          = "ml.m5.large"
  }

  lifecycle {
    create_before_destroy = true
  }
}

I did not have to let Terraform generate the aws_sagemaker_endpoint name, though.

I still think this issue should be addressed, either in the docs or by adding a name_prefix attribute to the aws_sagemaker_endpoint_configuration resource. I would be glad to implement both changes if it is OK with you!

@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 18, 2021
@Limess
Copy link
Contributor

Limess commented Dec 13, 2022

I agree adding a name_prefix would be useful here. The default terraform name is a pain to find in the UI.

Currently the other option seems to be to add something like a date generated by time_static as a suffix, but it's a bit painful to track all the changes which require the endpoint configuration to be recreated as it has a huge amount of configuration.

Limess added a commit to Limess/terraform-provider-aws that referenced this issue Jan 10, 2023
This allows a human readable name to be used when updating aws_sagemaker_endpoint_configuration in-place

Fixes hashicorp#21811
@ewbankkit ewbankkit added enhancement Requests to existing resources that expand the functionality or scope. and removed bug Addresses a defect in current functionality. labels Mar 30, 2023
@github-actions github-actions bot added this to the v4.62.0 milestone Mar 31, 2023
@github-actions
Copy link

github-actions bot commented Apr 7, 2023

This functionality has been released in v4.62.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented May 8, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/sagemaker Issues and PRs that pertain to the sagemaker service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants