“AWS CDK - StepFunction - CallAwsService”的 BatchGetBuilds 参数的正确格式是什么?

发布于 2025-01-10 14:52:46 字数 1928 浏览 1 评论 0原文

我正在为 CDK 的状态机工作。
并在检查状态机中的代码构建项目状态时遇到问题...

问。您能否告诉我 CallAwsServicebatchGetBuilds 参数的正确格式?

在此处输入图像描述

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",
    })

我尝试了两种方法。

  1. JsonPath.stringAt("$.results.codebuild.id")
    然后返回如下,执行失败。
"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")]
    如果我使用数组,它会在构建阶段失败...(我正在使用 cdk 管道来部署它)
    错误消息如下
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`?

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: "
quot;,
        resultSelector: { "status.
quot;: "$.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`?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾`听者〃 2025-01-17 14:52:46

您能否告诉我 CallAwsService 中的 batchGetBuilds 参数的正确格式?

使用 States.Array 内在函数。这些 CDK 语法是等效的:

parameters = {
  'Ids.

我可以在 CallAwsService 上使用此同步吗?

否。CallAwsService 任务实现 AWS SDK 服务集成,不支持 CodeBuild 操作的 .sync。从 v2.15 开始,如果您将 RUN_JOB (= .sync) 模式传递给 CallAwsService,CDK 应抛出错误。请参阅此 github 问题了解上下文。

或者我是否需要将 CallAwsService 更改为 CodeBuildStartBuild

是的。 CodeBuildStartBuild 有效正如 RUN_JOB 集成模式所预期的那样。

: 'States.Array($.results.codebuild.id)', Ids: JsonPath.stringAt('States.Array($.results.codebuild.id)'), Ids: JsonPath.array(JsonPath.stringAt('$.results.codebuild.id')) }

我可以在 CallAwsService 上使用此同步吗?

否。CallAwsService 任务实现 AWS SDK 服务集成,不支持 CodeBuild 操作的 .sync。从 v2.15 开始,如果您将 RUN_JOB (= .sync) 模式传递给 CallAwsService,CDK 应抛出错误。请参阅此 github 问题了解上下文。

或者我是否需要将 CallAwsService 更改为 CodeBuildStartBuild

是的。 CodeBuildStartBuild 有效正如 RUN_JOB 集成模式所预期的那样。

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

Use the States.Array intrinsic function. These CDK syntaxes are equivalent:

parameters = {
  'Ids.

Can I use this sync on the CallAwsService?

No. The CallAwsService task implements the AWS SDK service integrations, which does not support .sync for CodeBuild actions. As of v2.15, CDK should throw an error if you pass the RUN_JOB (= .sync) pattern to CallAwsService. See this github issue for context.

Or do I need to change the CallAwsService to CodeBuildStartBuild?

Yes. CodeBuildStartBuild works as expected with the RUN_JOB integration pattern.

: 'States.Array($.results.codebuild.id)', Ids: JsonPath.stringAt('States.Array($.results.codebuild.id)'), Ids: JsonPath.array(JsonPath.stringAt('$.results.codebuild.id')) }

Can I use this sync on the CallAwsService?

No. The CallAwsService task implements the AWS SDK service integrations, which does not support .sync for CodeBuild actions. As of v2.15, CDK should throw an error if you pass the RUN_JOB (= .sync) pattern to CallAwsService. See this github issue for context.

Or do I need to change the CallAwsService to CodeBuildStartBuild?

Yes. CodeBuildStartBuild works as expected with the RUN_JOB integration pattern.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文