英文:
How to use Terraform to deploy AWS Sagemaker Notebook instance
问题
不好意思,你的文本中有一些代码部分,我会忽略它们并只返回翻译的内容:
"Good day" 可以翻译为 "美好的一天"
"I have a local Jupyter notebook script that I would like to run from start to finish based on a Cloudwatch event." 可以翻译为 "我有一个本地的Jupyter笔记本脚本,我希望可以根据Cloudwatch事件从头到尾运行它。"
"The script it successfully started and stopped through two Lambdas (which works)." 可以翻译为 "这个脚本通过两个Lambda成功启动和停止(这部分是有效的)。"
"However, I am now struggling deploying the Sagemaker instance with the local script I have as the 'aws_sagemaker_notebook_instance' resource requires a 'aws_sagemaker_code_repository'." 可以翻译为 "然而,我现在在部署Sagemaker实例时遇到困难,因为'aws_sagemaker_notebook_instance'资源需要一个'aws_sagemaker_code_repository'。"
"Is it possible to provide the script by providing it as part of the terraform project like I do with a Lamdba?" 可以翻译为 "是否可以将脚本作为terraform项目的一部分提供,就像我在Lambda中那样?"
"I would very much like the project to be self-contained and not have external dependencies (like code repos) just to deploy the instance." 可以翻译为 "我非常希望这个项目是自包含的,不需要外部依赖(比如代码仓库)来部署实例。"
"Would I have to create a temporary repo as part of the deploy to satisfy 'aws_sagemaker_notebook_instance' requirements?" 可以翻译为 "我是否需要在部署过程中创建一个临时仓库以满足'aws_sagemaker_notebook_instance'的要求?"
"Thank you, any help or guidance would be appreciated." 可以翻译为 "谢谢,任何帮助或指导将不胜感激。"
英文:
Good day
I have a local Jupyter notebook script that I would like to run from start to finish based on a Cloudwatch event. The script it successfully started and stopped through two Lambdas (which works). However, I am now struggling deploying the Sagemaker instance with the local script I have as the "aws_sagemaker_notebook_instance" resource requires a "aws_sagemaker_code_repository".
Is it possible to provide the script by providing it as part of the terraform project like I do with a Lamdba? I would very much like the project to be self contained and not have external dependencies (like code repos) just to deploy the instance. Would I have to create a temporary repo as part of the deploy to satisfy "aws_sagemaker_notebook_instance" requirements?
Thank you, any help or guidance would be appreciated.
答案1
得分: 1
- 笔记本实例不需要代码存储库, 默认的代码存储库是可选资源(参考:https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sagemaker_notebook_instance)。因此,您应该能够创建一个笔记本实例而无需添加代码存储库。
- 您需要笔记本实例来做什么?如果您只是运行一个Python脚本,为什么不使用可以使用Lambda调用的训练作业(https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works-training.html)?如果您运行的是一个
.ipynb
文件,那么您可以按计划运行它们作为笔记本作业(尽管它们不支持基于事件的调度) - https://aws.amazon.com/blogs/machine-learning/operationalize-your-amazon-sagemaker-studio-notebooks-as-scheduled-notebook-jobs/ - 生命周期脚本(LCC)只是在创建/启动笔记本时执行的Shell脚本。作业是运行脚本/笔记本的更好方式,而不是使用Lambda启动和停止实例,只是为了运行LCC脚本。
英文:
A couple of pointers -
- The notebook instance does not require a code repository, the default code repository is an optional resource (ref: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sagemaker_notebook_instance). So, you should be able to create a notebook instance without adding a code repository.
- What do you need the notebook instance for? If you're simply running a Python script, why not use training jobs that can be invoked using Lambda (https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works-training.html)? If you're running an
.ipynb
file, then you can run them as notebook jobs on a schedule (they don't support event-based scheduling though) - https://aws.amazon.com/blogs/machine-learning/operationalize-your-amazon-sagemaker-studio-notebooks-as-scheduled-notebook-jobs/
Lifecycle scripts (LCC) are simply shell scripts that are executed on creating/starting a notebook. Jobs are better ways to run scripts/notebooks rather than starting and stopping an instance using Lambdas just to run a LCC script.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论