'What is the correct format of BatchGetBuilds parameters for 'AWS CDK - StepFunction - CallAwsService'

I'm working for a state machine by CDK.
And getting an issue to check the codebuild project status in the state machine...

Q. Could you let me know the correct format of batchGetBuilds parameters in CallAwsService?

enter image description here

import { CallAwsService } from "aws-cdk-lib/aws-stepfunctions-tasks"
import { JsonPath } from "aws-cdk-lib/aws-stepfunctions"

new CallAwsService(scope, "Check 1-1: Codebuild Status", {
        service: "codebuild",
        action: "batchGetBuilds",
        parameters: {
            Ids: [JsonPath.stringAt("$.results.codebuild.id")],
        },
        iamResources: ["*"],
        inputPath: "$",
        resultSelector: { "status.$": "$.builds[0].buildStatus" },
        resultPath: "$.results.bulidAmi",
    })

I tried 2 ways.

  1. JsonPath.stringAt("$.results.codebuild.id")
    Then it returns below and execution be failed.
"An error occurred while executing the state 'Check 1-1: Codebuild Status' (entered at the event id #9). 
The Parameters '{\"Ids\":\"******-generate-new-ami-project:05763ec2-89a6-4b56-8b44-************\"}' could not be used to start the Task:
[Cannot deserialize instance of `java.util.ArrayList<java.lang.Object>` out of VALUE_STRING token]"
  1. [JsonPath.stringAt("$.results.codebuild.id")]
    If I use array, it is failed in the build stage... (I'm using cdk pipeline to deploy this)
    error message is below
Cannot use JsonPath fields in an array, they must be used in objects



+ Extra Question
I found this during the search
https://stackoverflow.com/questions/70978385/aws-step-functions-wait-for-codebuild-to-finish

Can I use this `sync` on the `CallAwsService`? (Main 1... state is using `CallAwsService` also)
If yes, how can I use it..?
Or do I need to change the `CallAwsService` to `CodeBuildStartBuild`?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source