Patrik
Patrik

Reputation: 97

how to add sharedIdentifier to aws event bridge rule for scheduled execution of aws batch job

I configured aws bridge event rule (via web gui) for running aws batch job - rule is triggered but a I am getting following error after invocation:

shareIdentifier must be specified. (Service: AWSBatch; Status Code: 400; Error Code: ClientException; Request ID: 07da124b-bf1d-4103-892c-2af2af4e5496; Proxy: null)

My job is using scheduling policy and needs shareIdentifier to be set but I don`t know how to set it. Here is screenshot from configuration of rule:

enter image description here

There are no additional settings for subsequent arguments/parameters of job, the only thing I can configure is retries. I also checked aws-cli command for putting rule (https://awscli.amazonaws.com/v2/documentation/api/latest/reference/events/put-rule.html) but it doesn`t seem to have any additional settings. Any suggestions how to solve it? Or working examples?

Edited:

I ended up using java sdk for aws batch: https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-batch. I have a scheduled method that periodically spawns jobs with following peace of code:

AWSBatch client = AWSBatchClientBuilder.standard().withRegion("eu-central-1").build();

SubmitJobRequest request = new SubmitJobRequest()
    .withJobName("example-test-job-java-sdk")
    .withJobQueue("job-queue")
    .withShareIdentifier("default")
    .withJobDefinition("job-type");

SubmitJobResult response = client.submitJob(request);

log.info("job spawn response: {}", response);

Upvotes: 3

Views: 585

Answers (2)

Jacob Kearney
Jacob Kearney

Reputation: 429

I had a similar issue, from the CLI and the GUI, I just couldn't find a way to pass ShareIdentifier from an Eventbridge rule. In the end I had to use a state machine (step function) instead:

"States": {
    "Batch SubmitJob": {
      "Type": "Task",
      "Resource": "arn:aws:states:::batch:submitJob.sync",
      "Parameters": {
        "JobName": <name>,
        "JobDefinition": <Arn>,
        "JobQueue": <QueueName>,
        "ShareIdentifier": <Share>
      },
...

You can see it could handle ShareIdentifier fine.

Upvotes: 0

Yass
Yass

Reputation: 43

Have you tried to provide additional settings to your target via the input transformer as referenced in the AWS docs AWS Batch Jobs as EventBridge Targets ?

FWIW I'm running into the same problem.

Upvotes: 1

Related Questions