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

Merged
merged 11 commits into from
Feb 8, 2025

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 80.92%. Comparing base (f1d9a7d) to head (b3251d0).
Report is 12 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #32807   +/-   ##
=======================================
  Coverage   80.92%   80.92%           
=======================================
  Files         236      236           
  Lines       14253    14253           
  Branches     2490     2490           
=======================================
  Hits        11534    11534           
  Misses       2434     2434           
  Partials      285      285           
Flag Coverage Δ
suite.unit 80.92% <ø> (ø)

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

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

@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
@aws-cdk-automation aws-cdk-automation added pr/needs-maintainer-review This PR needs a review from a Core Team Member and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Jan 23, 2025
@QuantumNeuralCoder QuantumNeuralCoder self-assigned this Jan 28, 2025
Copy link
Contributor

@QuantumNeuralCoder QuantumNeuralCoder left a comment

Choose a reason for hiding this comment

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

See comment on default value set for payloadResponseOnly

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 28, 2025
@aws-cdk-automation
Copy link
Collaborator

This PR has been in the MERGE CONFLICTS state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

@mergify mergify bot dismissed QuantumNeuralCoder’s stale review February 2, 2025 03:42

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 2, 2025
Copy link
Contributor

@QuantumNeuralCoder QuantumNeuralCoder left a comment

Choose a reason for hiding this comment

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

Please see the proposed change.

@mergify mergify bot dismissed QuantumNeuralCoder’s stale review February 6, 2025 06:32

Pull request has been modified.

@@ -265,6 +265,8 @@ const getObject = new tasks.CallAwsServiceCrossRegion(this, 'GetObject', {

Other properties such as `additionalIamStatements` can be used in the same way as the `CallAwsService` task.

Note that when you use `integrationPattern.WAIT_FOR_TASK_TOKEN`, the output path changes under `Payload` property.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. Thanks for adding.

Copy link
Contributor

mergify bot commented Feb 6, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 6, 2025
Copy link
Contributor

mergify bot commented Feb 6, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mrgrain
Copy link
Contributor

mrgrain commented Feb 6, 2025

@Mergifyio dequeue

Copy link
Contributor

mergify bot commented Feb 6, 2025

This pull request has been removed from the queue for the following reason: pull request dequeued.

Pull request #32807 has been dequeued by a dequeue command

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

Copy link
Contributor

mergify bot commented Feb 6, 2025

dequeue

✅ The pull request has been removed from the queue default-squash

@mrgrain
Copy link
Contributor

mrgrain commented Feb 6, 2025

@Mergifyio requeue

Copy link
Contributor

mergify bot commented Feb 6, 2025

requeue

✅ The queue state of this pull request has been cleaned. It can be re-embarked automatically

Copy link
Contributor

mergify bot commented Feb 6, 2025

This pull request has been removed from the queue for the following reason: pull request manually updated.

The pull request #32807 has been manually updated

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

@mergify mergify bot dismissed QuantumNeuralCoder’s stale review February 6, 2025 20:25

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 6, 2025
@QuantumNeuralCoder
Copy link
Contributor

@Mergifyio requeue

Copy link
Contributor

mergify bot commented Feb 7, 2025

requeue

❌ This pull request head commit has not been previously disembarked from queue.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Copy link
Contributor

mergify bot commented Feb 8, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 8, 2025
Copy link
Contributor

mergify bot commented Feb 8, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@QuantumNeuralCoder QuantumNeuralCoder merged commit 800b775 into aws:main Feb 8, 2025
22 of 23 checks passed
Copy link

github-actions bot commented Feb 8, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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