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

fix(stepfunctions-tasks): CallAwsServiceCrossRegion doesn't work with WAIT_FOR_TASK_TOKEN #32807

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tmokmss
Copy link
Contributor

@tmokmss tmokmss commented Jan 9, 2025

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.

protected _renderTask(): any {
if (this.props.payloadResponseOnly) {
return {
Resource: this.props.lambdaFunction.functionArn,
...this.props.payload && { Parameters: sfn.FieldUtils.renderObject(this.props.payload.value) },
};
} else {
return {
Resource: integrationResourceArn('lambda', 'invoke', this.integrationPattern),
Parameters: sfn.FieldUtils.renderObject({
FunctionName: this.props.lambdaFunction.functionArn,
Payload: this.props.payload ? this.props.payload.value : sfn.TaskInput.fromJsonPathAt('$').value,
InvocationType: this.props.invocationType,
ClientContext: this.props.clientContext,
Qualifier: this.props.qualifier,
}),
};
}
}
}

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


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team January 9, 2025 05:53
@github-actions github-actions bot added bug This issue is a bug. effort/small Small work item – less than a day of effort p2 star-contributor [Pilot] contributed between 25-49 PRs to the CDK labels Jan 9, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@tmokmss tmokmss changed the title fix(stepfunctions-tasks): CallAwsServiceCrossRegion doesn't work with WAIT_FOR_TASK_TOKEN fix(stepfunctions-tasks): CallAwsServiceCrossRegion doesn't work with WAIT_FOR_TASK_TOKEN Jan 9, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 9, 2025 06:02

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.52%. Comparing base (f2ade56) to head (cbd8ecf).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #32807   +/-   ##
=======================================
  Coverage   81.52%   81.52%           
=======================================
  Files         222      222           
  Lines       13715    13715           
  Branches     2417     2417           
=======================================
  Hits        11181    11181           
  Misses       2254     2254           
  Partials      280      280           
Flag Coverage Δ
suite.unit 81.52% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 80.97% <ø> (ø)
packages/aws-cdk-lib/core 82.09% <ø> (ø)

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: cbd8ecf
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. star-contributor [Pilot] contributed between 25-49 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stepfunctions-tasks: CallAwsServiceCrossRegion doesn't work with WAIT_FOR_TASK_TOKEN
2 participants