【发布时间】:2021-04-19 14:16:59
【问题描述】:
我创建了一个stepfunction,下面这个状态机的定义(step-function.json)在terraform中使用(使用本页中的语法:https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateTransformJob.html)
如果我第一次执行这个状态机,它会创建一个名为 example-jobname 的 SageMaker 批量转换作业,但我需要每天执行这个状态机,然后它会给我错误 "error": "SageMaker.ResourceInUseException", "cause": "Job name must be unique within an AWS account and region, and a job with this name already exists 。
原因是因为作业名被硬编码为example-jobname所以如果状态机在第一次之后执行,由于作业名需要唯一,所以任务会失败,只是想知道如何添加一个字符串(类似于作业名称末尾的 ExecutionId)。这是我尝试过的:
-
我在 json 文件的
Parameters部分添加了"executionId.$": "States.Format('somestring {}', $$.Execution.Id)",但是当我执行任务时出现错误"error": "States.Runtime", "cause": "An error occurred while executing the state 'SageMaker CreateTransformJob' (entered at the event id #2). The Parameters '{\"BatchStrategy\":\"SingleRecord\",..............\"executionId\":\"somestring arn:aws:states:us-east-1:xxxxx:execution:xxxxx-state-machine:xxxxxxxx72950\"}' could not be used to start the Task: [The field \"executionId\" is not supported by Step Functions]"} -
我将json文件中的jobname修改为
"TransformJobName": "example-jobname-States.Format('somestring {}', $$.Execution.Id)",,执行状态机时报错:"error": "SageMaker.AmazonSageMakerException", "cause": "2 validation errors detected: Value 'example-jobname-States.Format('somestring {}', $$.Execution.Id)' at 'transformJobName' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-zA-Z0-9](-*[a-zA-Z0-9]){0,62}; Value 'example-jobname-States.Format('somestring {}', $$.Execution.Id)' at 'transformJobName' failed to satisfy constraint: Member must have length less than or equal to 63
我真的没有想法了,有人可以帮忙吗?非常感谢。
【问题讨论】:
标签: amazon-web-services terraform state-machine amazon-sagemaker aws-step-functions