首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在java中将OnStart脚本设置为CfnNotebookInstanceLifecycleConfigProps

如何在java中将OnStart脚本设置为CfnNotebookInstanceLifecycleConfigProps
EN

Stack Overflow用户
提问于 2021-09-13 13:17:23
回答 1查看 44关注 0票数 0

谷歌doid帮不了太多忙,sagemaker-1.121.0-sources.jar!/software/amazon/awscdk/services/sagemaker/CfnNotebookInstanceLifecycleConfigProps.java:102的亚马逊网络服务文档

代码语言:javascript
复制
  @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
    public Builder onStart(java.util.List<? extends java.lang.Object> onStart) {
        this.onStart = onStart;
        return this;
    }

问题是:如何在java中使用OnStart来传递OnStart脚本。我只是试着用CDK做similar的事情,而不是直接CloudFormation,结果卡住了。传递字符串列表(其中每一项都是一个bash命令)会导致异常。

提前感谢

代码语言:javascript
复制
//        the current varinal fails with
//        14:50:28.911  Error: Value did not match any type in union: Value did not match any type in union: Expected object reference, got "#!/bin/bash\n", Expected object reference, got "#!/bin/bash\n", Expected object reference, got ["#!/bin/bash\n","sudo -u ec2-user -i << 'EOF'","\n","echo 'export GRAPH_NOTEBOOK_AUTH_MODE=","DEFAULT' >> ~/.bashrc\n","echo 'export GRAPH_NOTEBOOK_HOST=${Token[TOKEN.509]} >> ~/.bashrc\n","echo 'export GRAPH_NOTEBOOK_PORT=-1.8881545897088608E289 >> ~/.bashrc\n","echo 'export NEPTUNE_LOAD_FROM_S3_ROLE_ARN=${Token[TOKEN.828]} >> ~/.bashrc\n"," aws s3 cp s3://aws-neptune-notebook/graph_notebook.tar.gz /tmp/graph_notebook.tar.gz","\n","rm -rf /tmp/graph_notebook","\n","tar -zxvf /tmp/graph_notebook.tar.gz -C /tmp","\n","/tmp/graph_notebook/install.sh","\n","EOF"]
//        14:50:28.911      at Kernel._toSandbox (/tmp/jsii-java-runtime3941392201016558027/lib/program.js:8726:23)
//        14:50:28.911      at /tmp/jsii-java-runtime3941392201016558027/lib/program.js:9283:37
//        14:50:28.911      at mapValues (/tmp/jsii-java-runtime3941392201016558027/lib/program.js:9554:35)
//        14:50:28.911      at Object.deserialize (/tmp/jsii-java-runtime3941392201016558027/lib/program.js:9279:28)
//        14:50:28.911      at Kernel._toSandbox (/tmp/jsii-java-runtime3941392201016558027/lib/program.js:8718:69)
//        14:50:28.911      at /tmp/jsii-java-runtime3941392201016558027/lib/program.js:8766:42
//        14:50:28.911      at Array.map (<anonymous>)
//        14:50:28.911      at Kernel._boxUnboxParameters (/tmp/jsii-java-runtime3941392201016558027/lib/program.js:8766:27)
//        14:50:28.911      at Kernel._toSandboxValues (/tmp/jsii-java-runtime3941392201016558027/lib/program.js:8752:29)
//        14:50:28.911      at /tmp/jsii-java-runtime3941392201016558027/lib/program.js:8367:75
//        14:50:28.911      at software.amazon.jsii.JsiiRuntime.processErrorResponse (JsiiRuntime.java:124)
//        14:50:28.911      at software.amazon.jsii.JsiiRuntime.requestResponse (JsiiRuntime.java:95)
//        14:50:28.911      at software.amazon.jsii.JsiiClient.createObject (JsiiClient.java:89)
//        14:50:28.911      at software.amazon.jsii.JsiiEngine.createNewObject (JsiiEngine.java:603)
//        14:50:28.911      at software.amazon.awscdk.services.sagemaker.CfnNotebookInstanceLifecycleConfig.<init> (CfnNotebookInstanceLifecycleConfig.java:33)
EN

回答 1

Stack Overflow用户

发布于 2021-09-15 12:58:12

使用CfnNotebookInstanceLifecycleConfig.NotebookInstanceLifecycleHookProperty

代码语言:javascript
复制
var lifeCycleOnStartHook = CfnNotebookInstanceLifecycleConfig.NotebookInstanceLifecycleHookProperty.builder()
                                                                                                     .content(
                                                                                                               Fn.base64(onStartCommand)
                                                                                                       )
                                                                                                       .build();
    var lcBuilder = CfnNotebookInstanceLifecycleConfigProps.builder()
                                                           .onStart(List.of(lifeCycleOnStartHook))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69163405

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档