Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(stepfunctions): invoke rest api with path from input #20252

Closed
florianbepunkt opened this issue May 8, 2022 · 3 comments · Fixed by #20323
Closed

(stepfunctions): invoke rest api with path from input #20252

florianbepunkt opened this issue May 8, 2022 · 3 comments · Fixed by #20323
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@florianbepunkt
Copy link

florianbepunkt commented May 8, 2022

Describe the bug

const callGetChannelApi = new sfnt.CallApiGatewayRestApiEndpoint(this, "Get channel", {
      api: adminApi,
      method: sfnt.HttpMethod.GET,
      stageName: "production",
      apiPath: sfn.JsonPath.format("/channels/{}", sfn.JsonPath.stringAt("$.channelId")), // << using a static string path works, this doesn't
      authType: sfnt.AuthType.IAM_ROLE,
      resultPath: "$.channel",
});

Expected Behavior

Input path should be resolved.

Current Behavior

CDK throws an error during deployment.

      throw new Error(`"path" must begin with a "/": '${path}'`);

Reproduction Steps

import * as sfn from "aws-cdk-lib/aws-stepfunctions";
import * as sfnt from "aws-cdk-lib/aws-stepfunctions-tasks";

const callGetChannelApi = new sfnt.CallApiGatewayRestApiEndpoint(this, "Get channel", {
      api: adminApi,
      method: sfnt.HttpMethod.GET,
      stageName: "production",
      apiPath: sfn.JsonPath.format("/channels/{}", sfn.JsonPath.stringAt("$.channelId")),
      authType: sfnt.AuthType.IAM_ROLE,
      resultPath: "$.channel",
});

const processExportSm = new sfn.StateMachine(this, "Process exports SM", {
      definition: callGetChannelApi,
    });

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.23.0 (build 50444aa)

Framework Version

No response

Node.js Version

v16.10.0

OS

MacOS X

Language

Typescript

Language Version

No response

Other information

No response

@florianbepunkt florianbepunkt added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 8, 2022
@github-actions github-actions bot added the @aws-cdk/aws-stepfunctions Related to AWS StepFunctions label May 8, 2022
@kaizencc kaizencc changed the title stepfunctions: invoke rest api with path from input (stepfunctions): invoke rest api with path from input May 10, 2022
@kaizencc
Copy link
Contributor

Thanks for opening the issue @florianbepunkt! Looks like the offending line is here:

https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-rest-api.ts#L60

We're calling arnForExecuteApi on the apigateway.IRestApi which is not equipped to handle jsonPath. Since apigateway should not need to know about jsonPaths, maybe the best way to fix this would be to recreate the arnForExecuteApi inside of CallApiGatewayRestApiEndpoint without the synth time checks.

@kaizencc kaizencc added p1 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels May 10, 2022
@kaizencc kaizencc removed their assignment May 10, 2022
@tejasmr
Copy link
Contributor

tejasmr commented May 12, 2022

@kaizencc can you review my PR #20294

@mergify mergify bot closed this as completed in #20323 May 18, 2022
mergify bot pushed a commit that referenced this issue May 18, 2022
Fixes #20252.

----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

wphilipw pushed a commit to wphilipw/aws-cdk that referenced this issue May 23, 2022
Fixes aws#20252.

----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants