AWS Step Functions wait for CodeBuild to finish
Asked Answered
H

1

5

How to wait for a CodeBuild to finish inside a Step Functions state machine?

The only wait I can think of right now is with a loop and a timer, like the flow bellow, but is it the only way to do it? Isn't there a "WaitForBuild" action or something like that?

enter image description here

Typo: BatchGetBuildBatches should be BatchGetBuilds.

Halftone answered 3/2, 2022 at 21:13 Comment(0)
H
6

I found out how to do this, just add .sync to the end of the resource arn of your CodeBuild start in your state machine json, like this:

{
  "Comment": "A description of my state machine",
  "StartAt": "CodeBuild StartBuild",
  "States": {
    "CodeBuild StartBuild": {
      "Type": "Task",
      "Resource": "arn:aws:states:::codebuild:startBuild.sync", // <--- here
      "Parameters": {
        "ProjectName": "arn:aws:codebuild:sa-east-1:############:project/test"
      },
      "End": true
    }
  }
}
Halftone answered 4/2, 2022 at 3:50 Comment(2)
Step Functions also needs permissions to interact with EventBridge and get the build details: * docs.aws.amazon.com/step-functions/latest/dg/… * docs.aws.amazon.com/step-functions/latest/dg/…Jipijapa
answer could be improved by explaining what .sync does and why its needed?Romilly

© 2022 - 2024 — McMap. All rights reserved.