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): add intrinsic functions #22431

Merged
merged 11 commits into from Oct 31, 2022
Merged

feat(stepfunctions): add intrinsic functions #22431

merged 11 commits into from Oct 31, 2022

Conversation

gkkachi
Copy link
Contributor

@gkkachi gkkachi commented Oct 9, 2022

Resolves #22068 and resolves #22629


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • 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

@gitpod-io
Copy link

gitpod-io bot commented Oct 9, 2022

@aws-cdk-automation aws-cdk-automation requested a review from a team October 9, 2022 11:11
@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Oct 9, 2022
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.

@aws-cdk-automation aws-cdk-automation dismissed their stale review October 9, 2022 11:43

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

Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! Please see my inline comments.

export function renderInExpression(x: string) {
const path = jsonPathString(x);
return path ?? singleQuotestring(x);
export function renderInExpression(x: any) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than throwing an error here for other types and accepting any, x should be typed to the specific valid types:

Suggested change
export function renderInExpression(x: any) {
export function renderInExpression(x: string | number) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renderInExpression can receive string[] here, so it should at least accept string[]. (Note that listAt returns string[]. )
We could restrict the input type by creating another function like renderListInExpression, but I think it is not necessary because the function is a "private" function.

https://github.com/gkkachi/aws-cdk/blob/ab29124d26cf8a21a1399b0193122c7b8419d00d/packages/%40aws-cdk/aws-stepfunctions/lib/fields.ts#L113-L115
https://github.com/gkkachi/aws-cdk/blob/ab29124d26cf8a21a1399b0193122c7b8419d00d/packages/%40aws-cdk/aws-stepfunctions/test/fields.test.ts#L241

Copy link
Contributor

Choose a reason for hiding this comment

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

If it can accept string[], the logic isn't quite right, then. You throw an error if it's not string or number.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, please write tests against the various input types you'd expect here and at least one failure case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wrote tests for renderInExpression . d32fbf3

/*
* Stack verification steps:
*
* -- aws stepfunctions describe-state-machine --state-machine-arn <stack-output> has a status of `ACTIVE`
Copy link
Contributor

Choose a reason for hiding this comment

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

This should use an assertion in code to verify instead of being added here in text.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created this integration test based on this.
I think it is not necessary to execute describe-state-machine explicitly to confirm that the state machine is deployed successfully because successful deployment of cfn stack means that state machine deployments are also succeeded, so I deleted the comment by 926c938.

https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-stepfunctions/test/integ.custom-state.ts

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the assertion anyway. We didn't have that library when the older test was written but we do have that capability now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I added it. d2ff6e1

@mergify mergify bot dismissed TheRealAmazonKendra’s stale review October 15, 2022 02:08

Pull request has been modified.

Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

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

Comments inline.

@mergify mergify bot dismissed TheRealAmazonKendra’s stale review October 19, 2022 16:27

Pull request has been modified.

@github-actions github-actions bot added effort/medium Medium work item – several days of effort p1 and removed p2 effort/small Small work item – less than a day of effort labels Oct 27, 2022
@TheRealAmazonKendra TheRealAmazonKendra changed the title feat(aws-stepfunctions): Add missing intrinsic functions feat(stepfunctions): add intrinsic functions Oct 31, 2022
@mergify
Copy link
Contributor

mergify bot commented Oct 31, 2022

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).

@mergify mergify bot dismissed TheRealAmazonKendra’s stale review October 31, 2022 20:01

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Oct 31, 2022

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
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 8d337cf
  • 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 8f85b08 into aws:main Oct 31, 2022
@mergify
Copy link
Contributor

mergify bot commented Oct 31, 2022

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).

if (path) return path;
if (typeof x === 'number') return x.toString(10);
if (typeof x === 'string') return singleQuotestring(x);
throw new Error('Unxexpected value.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra x in unexpected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1
Projects
None yet
4 participants