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

feat(stepfunctions-tasks): await the eval so async ops can be passed to tasks.EvaluateExpression #16290

Merged
merged 2 commits into from
Sep 2, 2021

Conversation

3p3r
Copy link
Contributor

@3p3r 3p3r commented Aug 31, 2021

Currently the way EvaluateExpression is set up, if you pass an async expression to it, it never waits for the execution to complete. By adding an await before the eval() call, async ops can be passed in. This also works for sync ops same as before (await works with sync code as well).


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

@gitpod-io
Copy link

gitpod-io bot commented Aug 31, 2021

@mergify
Copy link
Contributor

mergify bot commented Aug 31, 2021

Title does not follow the guidelines of Conventional Commits. Please adjust title before merge.

@3p3r 3p3r changed the title await the eval so async ops can be passed to tasks.EvaluateExpression feat: await the eval so async ops can be passed to tasks.EvaluateExpression Aug 31, 2021
@peterwoodworth peterwoodworth added p1 effort/small Small work item – less than a day of effort @aws-cdk/aws-stepfunctions-tasks labels Sep 1, 2021
@BenChaimberg BenChaimberg changed the title feat: await the eval so async ops can be passed to tasks.EvaluateExpression feat(stepfunctions-tasks): await the eval so async ops can be passed to tasks.EvaluateExpression Sep 2, 2021
@BenChaimberg
Copy link
Contributor

Thanks for your contribution! Can you just give me an example of such an asynchronous operation?

@3p3r
Copy link
Contributor Author

3p3r commented Sep 2, 2021

@BenChaimberg absolutely! here is a snippet I have in my step function which is currently not possible without this patch:

new tasks.EvaluateExpression(this, 'test', {
  expression: `(async () => {
    const AWS = require("aws-sdk");
    const iam = new AWS.IAM();
    return await iam.listRoles().promise();
  })()`,
  resultPath: "$.roles"
})

The addition of the await before the eval() in the patch allows me to run this async code and actually wait for it to finish processing before control is handed back to my state machine.

@BenChaimberg BenChaimberg added the pr-linter/exempt-readme The PR linter will not require README changes label Sep 2, 2021
@BenChaimberg BenChaimberg added the pr-linter/exempt-test The PR linter will not require test changes label Sep 2, 2021
@mergify
Copy link
Contributor

mergify bot commented Sep 2, 2021

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: d70093d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify mergify bot merged commit 174b066 into aws:master Sep 2, 2021
@mergify
Copy link
Contributor

mergify bot commented Sep 2, 2021

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

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Sep 6, 2021
…to tasks.EvaluateExpression (aws#16290)

Currently the way `EvaluateExpression` is set up, if you pass an async expression to it, it never waits for the execution to complete. By adding an `await` before the `eval()` call, async ops can be passed in. This also works for sync ops same as before (await works with sync code as well).

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
david-doyle-as24 pushed a commit to david-doyle-as24/aws-cdk that referenced this pull request Sep 7, 2021
…to tasks.EvaluateExpression (aws#16290)

Currently the way `EvaluateExpression` is set up, if you pass an async expression to it, it never waits for the execution to complete. By adding an `await` before the `eval()` call, async ops can be passed in. This also works for sync ops same as before (await works with sync code as well).

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@3p3r 3p3r deleted the patch/tasks-evaluate-expression-async branch September 14, 2021 19:37
@jorge-ortega
Copy link

This change seems to have been reverted by this commit. Was this intentional?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-stepfunctions-tasks effort/small Small work item – less than a day of effort p1 pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-test The PR linter will not require test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants