Skip to content

Commit

Permalink
fix(stepfunctions-tasks): CallAwsServiceCrossRegion doesn't work wi…
Browse files Browse the repository at this point in the history
…th WAIT_FOR_TASK_TOKEN (#32807)

### Issue # (if applicable)

Closes #32746

### Reason for this change

The Step Functions task `CallAwsServiceCrossRegion` did not work with
`integrationPattern.WAIT_FOR_TASK_TOKEN`. This PR fixes the problem.

### Description of changes

The root cause of this problem is that we used an alterntive form of
calling Lambda Invoke, which does not support waitForTaskToken
integration pattern.

> Alternatively, you can invoke a Lambda function by specifying a
function ARN directly in the "Resource" field. When you invoke a Lambda
function in this way, you can't specify .waitForTaskToken, and the task
result contains only the function output.


https://docs.aws.amazon.com/step-functions/latest/dg/connect-lambda.html#connect-lambda-api-examples


This PR fixes the code to align with the implementation in
`LambdaInvoke` task, which supports both integration pattern.


https://github.com/aws/aws-cdk/blob/bbdd42c8f45916d5c6945f3429916f6199d2ec66/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/lambda/invoke.ts#L146-L165

To fix this without breaking changes, we introduce `payloadResponseOnly`
property (true by default), and fix the `_renderTask` method as above.
Users who need other integration patterns can set `payloadResponseOnly:
false`.

Additionally we throw an error if `payloadResponseOnly == true &&
integrationPattern != REQUEST_RESPONSE` to prevent misconfiguration.
This is not a breaking change because the construct previously did not
work at all when `integrationPattern != REQUEST_RESPONSE`.


### Describe any new or updated permissions being added

No.

### Description of how you validated changes

Added unit tests and integ tests.

### Checklist
- [X] My code adheres to the [CONTRIBUTING
GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
[DESIGN
GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
  • Loading branch information
QuantumNeuralCoder authored Feb 8, 2025
2 parents f1d9a7d + b3251d0 commit 800b775
Show file tree
Hide file tree
Showing 14 changed files with 33,241 additions and 11 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 800b775

Please sign in to comment.