CloudFormation with SageMaker LifeCycleConfig without leaving the instance running

0

I have a use case with SageMaker in which I want to create a notebook instance using CloudFormation. I have some initialization to do at creation time (clone a github repo, etc.). That all works fine. The only problem is that I would like to do this ahead of time in a set of accounts, and there doesn't appear to be any way to leave the newly-created instance in a Stopped state. A property in the CFT would be helpful in this regard.

I tried using the aws cli to stop the instance from the lifecycle create script, but that fails as shown in the resulting CloudWatch logs:

An error occurred (ValidationException) when calling the StopNotebookInstance operation: Status (Pending) not in ([InService]). Unable to transition to (Stopping) for Notebook Instance (arn:aws:sagemaker:us-east-1:147561847539:notebook-instance/birdclassificationworkshop).

Interestingly, when I interactively open a notebook instance, open a terminal in the instance, and execute a "stop-notebook-instance" command, SageMaker is happy to oblige. I would have thought it would let me do the same in the lifecycle config. Unfortunately, SageMaker still has the notebook in the Pending state at that point, so "stop" is not permitted.

Are there other hooks or creative options anyone can provide for me?

AWS
MarkRoy
demandé il y a 6 ans832 vues
1 réponse
0
Réponse acceptée

One solutions will be to create a CFN custom resource backed by lambda. You can configure to run this resource only when the notebook resource completed. and use the lambda function to stop the notebook using one of our SDKs.

répondu il y a 6 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions