使用 Step Functions 執行 AWS Batch 工作負載 - AWS Step Functions

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 Step Functions 執行 AWS Batch 工作負載

您可以將 Step Functions 與 整合 AWS Batch ,以在 AWS 雲端中執行批次運算工作負載。此頁面列出支援的 , AWS Batch APIs並提供執行批次處理任務的範例Task狀態。

若要了解如何在 Step Functions 中整合 AWS 服務,請參閱 整合 服務將參數傳遞至 Step Functions API中的服務

Optimized AWS Batch Integration 的主要功能

請注意, 請求回應使用任務權杖等待回呼整合模式沒有最佳化。

下列包含提交 AWS Batch 任務並等待任務完成Task的狀態。

{ "StartAt": "BATCH_JOB", "States": { "BATCH_JOB": { "Type": "Task", "Resource": "arn:aws:states:::batch:submitJob.sync", "Parameters": { "JobDefinition": "preprocessing", "JobName": "PreprocessingBatchJob", "JobQueue": "SecondaryQueue", "Parameters.$": "$.batchjob.parameters", "ContainerOverrides": { "ResourceRequirements": [ { "Type": "VCPU", "Value": "4" } ] } }, "End": true } } }

支援的 AWS Batch APIs:

中的參數 Step Functions 以 表示 PascalCase

即使原生服務API位於 中camelCase,例如 API 動作 startSyncExecution,您也可以在 中指定參數 PascalCase,例如:StateMachineArn

IAM 用於呼叫 的政策 AWS Batch

下列範例範本顯示 如何根據您狀態機器定義中的資源 AWS Step Functions 產生IAM政策。如需詳細資訊,請參閱 Step Functions 式如何為整合式服務產生IAM原則探索 Step Functions 中的服務整合模式

由於 AWS Batch 提供資源層級存取控制的部分支援,您必須使用 "Resource": "*"

Run a Job (.sync)
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "batch:SubmitJob", "batch:DescribeJobs", "batch:TerminateJob" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "events:PutTargets", "events:PutRule", "events:DescribeRule" ], "Resource": [ "arn:aws:events:[[region]]:[[accountId]]:rule/StepFunctionsGetEventsForBatchJobsRule" ] } ] }
Request Response
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "batch:SubmitJob" ], "Resource": "*" } ] }