terraform-aws-sagemaker icon indicating copy to clipboard operation
terraform-aws-sagemaker copied to clipboard

Failing to recreate SageMaker notebook instance

Open agrounds opened this issue 4 months ago • 0 comments

If a SageMaker notebook instance created with this module is tainted, it will fail to recreate.

Steps to reproduce

  1. Create a SageMaker notebook instance with this module. Specify a particular name with the sagemaker_notebook_instance_name variable.
  2. Taint and attempt to create the notebook instance, for instance by using the command terraform apply -replace='module.sagemaker.aws_sagemaker_notebook_instance.sagemaker_notebook_instance[0]'

Error messages

Error: creating SageMaker Notebook Instance: ValidationException: Cannot create a duplicate Notebook Instance (arn:aws:sagemaker:<region>:<account id>:notebook-instance/<notebook name>)
  status code: 400, request id: <request id>  

  with module.sagemaker.aws_sagemaker_notebook_instance.sagemaker_notebook_instance[0],
  on .terraform/modules/sagemaker/sagemaker_notebook_instance.tf line 4, in resource "aws_sagemaker_notebook_instance" "sagemaker_notebook_instance":
   4: resource "aws_sagemaker_notebook_instance" "sagemaker_notebook_instance" {

Suggested fix

I believe this is due to this configuration. If the notebook were destroyed first, then recreated, this issue would be avoided.

agrounds avatar Feb 29 '24 17:02 agrounds